LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   merge columns from multiple files in a directory based on match of two columns (https://www.linuxquestions.org/questions/linux-newbie-8/merge-columns-from-multiple-files-in-a-directory-based-on-match-of-two-columns-4175558659/)

prasanthi yanamala 11-12-2015 05:38 AM

merge columns from multiple files in a directory based on match of two columns
 
Hi all,
I want to merge columns from multiple files(each file may have different number of columns and different column headers but only two headers in common) in a directory based on match of two common columns.Below are the sample files

file1

NAME,Time,Rx_bytes,Tx_bytes,SNR
a,11:01:00,1,2,,
c,11:01:00,3,4,5
e,11:01:00,6,,

file2
NAME,Time,Speed,RPM
g,11:01:00,34,56
i,11:01:00,45,55
a,11:02:00,45,65


file3
NAME,Time,Cycles,Errors,BW
c,11:01:00,2,3,4
e,11:01:00,32,21,34
a,11:01:00,68,79,
g,11:01:00,33,44,
k,11:01:00,23,34,54

...and so on some files like this
I need the output like this

result_file1.csv
NAME,Time,Rx_bytes,Tx_bytes,SNR,Speed,RPM,Cycles,Errors,BW
a,11:01:00,1,2,,,,68,79,
a,11:02:00,,,,45,65,,,

result_file2.csv

NAME,Time,Rx_bytes,Tx_bytes,SNR,Cycles,Errors,BW
c,11:01:00,3,4,5,2,3,4,32,21,34

result_file3.csv
NAME,Time,Speed,RPM,Cycles,Errors,BW
e,11:01:00,6,,

result_file4.csv
NAME,Time,Speed,RPM,Cycles,Errors,BW
g,11:01:00,34,56,33,44,

and so on like this.

I want to form result files based on the column 'NAME' and with sorted 'TIME'

Thanks in advance

chrism01 11-12-2015 06:03 AM

So, what code have you got so far?

grail 11-12-2015 11:11 AM

Firstly, please use [code][/code] tags around code and data.

Also, please provide details on how the result files are to get the extra columns shown? Where does the information for the extra columns come from?

And as above, what have you done so far and if looking for a complete start, what language are you looking to use?


All times are GMT -5. The time now is 06:18 AM.