I don't understand what your code was trying to do by setting elements of your C[] array to -9999. Although not tested with the sample input you provided, I assume that you were setting elements of your V[] array to -9999 to give each field a default value if there is no line in an input record for a given field.
The following code gathers field headers from the 1st input record and gathers data from subsequent records ignoring headers (field 1 values) that were not found in the 1st record. If fields are missing from other input records the default value of -9999 will be printed as the value for those fields. The order of fields in the first input record determines the order of fields in all of the output records.
If this is what you were trying to do, the following code is considerably shorter than the code you were using and produces the same output that your code produced when given the DOS text format input file you uploaded as file.txt:
Note that if you would like to get rid of the trailing space in each field in the header output line, you can do that by changing the line:
in the script above to:
Although I don't have gawk, the above code should work with gawk as well as with awk. If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
This User Gave Thanks to Don Cragun For This Post:
Hi,
I have a text file like
----------------------
aaa|bbb|ccc|ddd|eee
fff|gggg|hhhhhh|kkkk
--------------------
I have a script which will transfer(thourgh FTP) this text file to windows system.
But I want to covert it into excel or CSF then upload into windows system..
thanks (9 Replies)
Hi i have wriiten a script which fetches the data from text file, and saves in the output in a text file itself, but i want that the output should save in different columns.
I have the output like:
For Channel:response_time__24.txt
1547 data points
0.339
0.299
0.448
0.581
7.380
... (1 Reply)
hi all,
i have a select query that gives me the output in the following way...
SYSTYPE
--------------------------------------------------------------------------------
Success Failures Total RFT
---------- ---------- ---------- ----------
TYP
1 0 ... (3 Replies)
Hi ,
I have a simple text file with contents as below:
12345678900 971,76 4234560890
22345678900 5971,72 5234560990
32345678900 71,12 6234560190
the new csv-file should be like:
Column1;Column2;Column3;Column4;Column5
123456;78900;971,76;423456;0890... (9 Replies)
Gents
Using the script attached (raw2csv). i use to create the file .csv.. The input file is called 201.raw.
Kindly can you check if there is easy way to do it. The script works fine but takes a lot time to process
Thanks for your help (8 Replies)
Hi guys,
I have a text file named file1.txt that is formatted like this:
001 , ID , 20000
002 , Name , Brandon
003 , Phone_Number , 616-234-1999
004 , SSNumber , 234-23-234
005 , Model , Toyota
007 , Engine ,V8
008 , GPS , OFF
and I have file2.txt formatted like this:
... (2 Replies)
I am working on a text file where I have to get data from a text file and convert it into either CSV format or Column format as shown below.
OUTPUT Expected
GRP Name Pair Size DName DNumber PName PNumber
adm_grp Pair1 150.00KG Pair_0ABC_1 0396 Pair_0267_s 1292
... (6 Replies)
I have input data looks like this which is a part of a csv file
7,1265,76548,"0102:04"
8,1266,76545,"0112:04"
I need to make the output data should look like this and the output data will be part of text file:
7|1265000 |7654899 |A|
8|12660000 |76545999 |B|
The logic behind the... (6 Replies)
Gents,
I am trying to create a csv file using the file attached.
I have a problem to get all information required because the rows are not continues.
Here is my code till now.
awk ' /"ffid"/{if(s){print s;s=$NF}else{s=$NF}}
/"LineNumber"/{s=s $NF}
/"PointNumber"/{s=s $NF}... (4 Replies)