LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-12-2015, 04:38 AM   #1
prasanthi yanamala
LQ Newbie
 
Registered: Nov 2015
Posts: 1

Rep: Reputation: Disabled
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
 
Old 11-12-2015, 05:03 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,649

Rep: Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483Reputation: 2483
So, what code have you got so far?
 
Old 11-12-2015, 10:11 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,715

Rep: Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
merge columns from multiple files vijay_babu1981 Linux - Newbie 21 06-24-2014 06:59 AM
how to merge multiple columns into one column linuxon Linux - Newbie 6 03-14-2012 11:17 AM
merge multiple files each with two columns. 11st col same but may have difft values newbie271 Linux - Newbie 2 01-10-2012 06:03 PM
[SOLVED] bash script: merge files comparing columns... masavini Programming 18 04-23-2011 05:01 AM
Is there a command to merge two files as two columns of one file? davee Linux - General 2 07-19-2005 10:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration