How to merge csv files onto a single file on condi

2019-03-02 03:00发布

I have multiple csv files on folder. The column headers are different but column datas are same.

The number inside the bracket is actual column name. Item(67) 67 is column name

So ignore the string Item and only consider the int inside () and perform the operation.

Sample Files: https://drive.google.com/open?id=1q7c1AqCRKRufSVh--9o0W6rdz28QyBGa

Explanation:

The files on the drive should be appended together. On Condition based on the column names. If the integer on condition matches with the column name(integer inside () of the column name) then it should be placed on that column. Please check the expected output.
Files

File1: ID Item(67) Item (89) Item (91) Item (100)
       1    56      78        98        101     
       2    91      100       121       
File2: ID Item(96) Item (58) Item (99) Item (105)
       3  101      102        103       104
       4  112      113        117       119

Condition

 File  Price1 Price2 Price3 Price4
 File1 67      89     91     100
 File2 96      58     105     99

Expected Output:

  File  ID   Price1 Price2 Price3 Price4
  File1  1    56      78    98     101     
  File1  2    91      100   121
  File2  3    101     102  104     103       
  File2  4     112      113  119      117  

标签: shell
0条回答
登录 后发表回答