Text file to Excel adding column
Hi,
I am new to linux. I am currently doing a script to write text file to excel file.I have may text files with 2 columns each.When i write excel file from one text file and try to append the next text file's data in excel , i am getting the datas in rows.. but i need them in column. One thing is the first column in all text files are same. so i would like to have an excel with first column once and the remaining columns(only 2nd column from remaining files). i used the below script. i had the text files - log1, log2, log3, log4 ( echo "count, time1"; sed 's/\s\+/,/g' log1) >Log.csv ( echo "time2"; awk -F' ' '{ print $2 }' log2) >> Log.csv ( echo "time3"; awk -F' ' '{ print $2 }' log3) >> Log.csv ( echo "time4"; awk -F' ' '{ print $2 }' log3) >> Log.csv |
Welcome to LQ!
I think that the 'paste' command should achieve your desired result. i.e.'paste log1 log2 log3 log4 > log.csv' You may want to further format the file using 'colrm' to delete columns and 'sed' to change tab characters to comma space delimiters. This could also be handled within Excel. It is a little difficult to be more precise without knowing the exact data format. |
|
Maybe a bit advanced for a novice (?), but let's unleash the power of awk:
Code:
awk ' |
All times are GMT -5. The time now is 10:42 AM. |