As has been stated many times, your requirement for a CSV output file and your requirement for fixed width output fields are conflicting requirements. The fact that you have presented three different versions of your desired output (and none of them match any of your descriptions of your desired output) adds to the confusion.
Furthermore, you have shown us seven lines of input and four lines of output (not counting the added header line) with no indication of why some input lines are supposed to be removed from the output. You say you want fixed width fields, but the headers in two or your three output samples do not have the headers lined up with the corresponding field data. Your sample input seems to have constant width data for the 1st two output fields, and variable width data for the last output field, but there is no indication whether the input will be fixed length for those two fields or if that just happens to be true for the seven sample lines provided.
Some of your sample output uses a tab and 2 spaces as an output field separator, some uses just a tab, some uses a tab and 10 spaces, some uses a tab and 1 space, one uses a tab and 16 spaces, and one uses a tab and 12 spaces.
The following awk script produces fixed width output for the 1st two columns making the 1st output field 8 characters wider than the widest corresponding input field, the 2nd output field 6 characters wider than the widest corresponding input field, and a variable length final field with no padding added to the corresponding input field. (This seems to match some of the lines specified in your first sample output.) The headers are lined up with the underlying field data.
with the sample Output.TXT contents you provided in post #1 in this thread, produces the output:
and with the input:
produces the output:
If you want to try this script on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk.
Hopefully, this is close to what you want. If not, you MUST give us a clear specification of your input file format and a clear specification of your desired output file format or we are all wasting our time trying to help you.
This User Gave Thanks to Don Cragun For This Post:
Hi ,
I have a Txt file which consist of 1000's of SOAP request and response and i want the file to be converted to a csv file like column a should have a soap request and column b should have the soap response . can someone assist me in achieving this please ?
Thanks (2 Replies)
My concnern related to the post
-Convert shell script output txt file to html table,
in this how to print the heading as color.
awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Hi,
I have made a a script which creates a csv file as daily database report
However i want to covert that csv file to html because csv file does not have a good visibilty.
So it is possible to have such csv to html coversion script.
Your prompt help much appreciated. Thanks in advance (4 Replies)
Hi people. I've finally converted to linux, and I'm starting to explore the amazing capabilities of the terminal. At the moment in trying to learn how to extract text using the "grep" and "sed" command. I decided to learn by trying to figure out how to solve a practical problem. I have a schedule... (4 Replies)
Hi,
I have script which generates the output as below:
Jobname Date Time Status
abc 12/9/11 17:00 Completed
xyz 13/9/11 21:00 Running
I have the output as a text file. I need to convert it into a HTML Table and sent it thru email
... (6 Replies)
Hi - I am looking to convert the following text to csv. The columns may not always have data in them and they may have varying spaces but I still need to have a comma there anyway:
Sample Data:
~~~~~~~
Name Email Location Phone
Tom... (4 Replies)
hi...... thanks for allowing me to start a discussion
i am collecting usb usage details of all users and convert it into csv files so that i can export it into some database..
the input text file is as follows:-
USB History Dump
by nabiy (c)2008
(1) --- Kingston DataTraveler 130 USB... (2 Replies)
Hi,
I was trying some split command to pull out values like "uid=abc,ou=INTERNAL,ou=PEOPLE" into a csv file. However because of erratic nature of occurrance of rows made me stopped. Could someone help me in this? and if someone has a one liner for this?
The text file contain pattern like this... (14 Replies)
Hi,
i don't know anything about PERL. Can anyone help me providing PERL scripts for
1. converting XLS to CSV (and vice-versa)
2. converting DOC/RTF to TXT
Thanks much
Prvn (1 Reply)