Convert columns of data into rows
Hi,
I have the following CSV file (file name system1.csv); TIME,data_in1,data_in2,data_out1,data_out2,Total_in,total_out 0900,10,9,5,10,15,24 1000,11,10,6,11,17,26 1100,12,11,7,12,19,28 1200,13,12,8,13,21,30 1300,14,13,9,14,23,32 1400,15,14,10,15,25,34 Now, I need to create an out put file, last two columns as a row of data (using the first columns as heading) with the file name as first row. For an example the out put file should look like; system_name,0900_in,1000_in,1100_in,1200_in,1300_in,1400_in,0900_out,1000_out,1100_out,1200_out,1300 _out,1400_out system1,15,17,19,21,23,25,24,26,28,30,32,34 I need to run a script to do above conversion. Need your help. Jaufe |
Use "cut -c<column-beging>-<column-end> <input-file>" for extracting from columns from a file.
for example, in your case "cut -c1-4 input_file" for extracting first 4 chars from each line. Also if you have a known delimiter for the to-be-extracted column, you can use "cut -d" along with delimiter. There can be a million other ways to do the same. these are the easiest IMHO. Hope this helps -jork |
Quote:
|
Quote:
Code:
#!/usr/bin/env ruby My royalty fee is only 3 cents per script execution or 1 cent per file processed -- which ever is more expensive. ;) |
All times are GMT -5. The time now is 09:15 PM. |