Concatenating many files based on a specific column contents
Dear all,
I have many files(.csv) in a directory.
I want to concatenate the files which have similar entries in a particular column and save into a new file like result_datetime.csv etc.
One example file is like below.
and one more example is like below.
Here both files have similar entries for col2(Step).
So we need to concatenate these files.
Like this we need to scan all the files in the folder and look for specific column entries and concatenate all similar files.
Your script has some logical problem.
Suppose if I change my file3 contents like below, then the script should ignore this file(file3) as the 2nd column contents across file3 and other two files(file1 and file2 is not 1-to-1).
But I am getting the output like below. When I run your script with file1 file2 file3 as puts.
Basically the script should print the output from all the files which has similar (exact) column values (i.e. it should treat whole column as the key not the individual rows).
Let me know if you still have problem in understanding my requirement.
Your script has some logical problem.
Suppose if I change my file3 contents like below, then the script should ignore this file(file3) as the 2nd column contents across file3 and other two files(file1 and file2 is not 1-to-1).
But I am getting the output like below. When I run your script with file1 file2 file3 as puts.
Basically the script should print the output from all the files which has similar (exact) column values (i.e. it should treat whole column as the key not the individual rows).
Let me know if you still have problem in understanding my requirement.
I'm new to shell programming, I have a huge text file in the following format, where columns are separated by single space:
ACA MEX 4O_ $98.00 $127.40 $166.60 0:00 0:00 0 ;
ACA YUL TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ;
ACA YYZ TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ;
ADZ YUL TS_ $300.00... (3 Replies)
Good day all.
Using basic UNIX/Linux tools, how would you delete a line based on a character found in column 1?
For example, if the CITY name contains an 'a' or 'A', delete the line:
New York City; New York
Los Angeles; California
Chicago; Illinois
Houston; Texas
Philadelphia;... (3 Replies)
Here is my dir structure:
/tmp/dave/myappend.txt
/tmp/dave/dir1/test.txt
/tmp/dave/dir2/test.txt
/tmp/dave/dir3/test.txt
/tmp/dave/dir4/test.txt
I want to append the contents of myappend.txt to the end of each file with the name "test.txt" in all dirs in /tmp/dave/
I have tried this:... (2 Replies)
Hi,
I have a tab delimited text file from which I want to cut out specific columns. If the second column equals one, I want to cut out columns 1 and 5 and 6. If the second column equals two, I want to cut out columns 1 and 5 and 7. How do I go about doing that? Thanks! (4 Replies)
Hi,
I have a unix file with the below structure -
CustId1 CustName1 CustPhn1 /u/home/xmldata/A000001
CustId2 CustName2 CustPhn2 /u/home/xmldata/A000002
CustId3 CustName3 CustPhn3 /u/home/xmldata/A000003
Then I have another unix directory /u/home/xmldata
This directory has... (3 Replies)
Hello everyone,
I currently have a situation which is causing me some issues for keeping up with certain files. I will explain this to the best of my abilities.
I have a list of files as follows
50_REPORT_1111 - file contains the word Car
50_REPORT_2222 - file contains the word House... (15 Replies)
Hi,
I have a file f1 having the contents as below
select (<condn>) from dual
I have another file f2 having the contents as below
1,
2,
3
I want to replace <condn> in f1 with the contents of f2
I tried using sed like this
sed "s:<condn>:`cat f2`:g" f1
The above command resulted in sed:... (3 Replies)
HI,
Your help was great: awk -F":" '$5 ~ /^P/{print }' file
I would like to know what changes need to be done to this line code, so that I can put it in a shell script and call it as the example below.
example: countries that start with chacater 'P'
> country P
Result:
... (0 Replies)
Hi,
I have a file that has several values seperated by ":"
2006:John:Student:Football:Portugal:Cinema
2006:James:Engineer:Basket:Poland:Theatre
2007:Lucy:Diver:Gymnastic:England:Music
2007:Smith:Plumber:Basket:Spain:Poker
I need make a filter based on the 5th field to find countries that... (1 Reply)