Joining and sorting with csvs with subfields


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Joining and sorting with csvs with subfields
# 8  
Old 10-24-2014
Hello Senhia83,

Following may help in same.

Code:
awk -F"," 'FNR==NR{S=$1;$1="\b";A[S]=$0;next} ($1 in A){print $0 OFS A[$1]}' OFS=, file2 file1

Output will be as follows.
Code:
a,b,"c,d,e",1,
f,g,h,2,"j,j"

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 9  
Old 10-25-2014
Based on your given input & desired output, couldn't you just use:join -t',' file1 file2
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join 2 CSVs based on 1 key

Hello, I have 2 csv as follows: a.csv: name,phone,adress,car xy,1234,asbd yz,2134,asbdf tc,6789,salkdur b.csv: telphone,vehicle 2134,toyota 6789,bmw 1234,honda What is need is this: output.csv: name,phone,adres,car xy,1234,asbd,honda yz,2134,asbdf,toyota (7 Replies)
Discussion started by: Zam_1234
7 Replies

2. Shell Programming and Scripting

Merge csvs with column headers

hello gurus, Somebody must have done this before, I couldn't find anything. Please redirect me if this was solved before, and if not please help. To the problem now, I have multiple csv files (about 1000) which I need to concatenate by column header. The final file should have a superset... (4 Replies)
Discussion started by: abh.kumar
4 Replies

3. Shell Programming and Scripting

Lookup subfields from 3 tables and insert

Hello masters, Please help on the following. I have a tab delimited file with subfields space delimited. 1 a b x y hhghd ghgf 2 v t f g gdgdgdg hghg I have 3 lookup table files tab delimited, for fields 2,3 and 4 respectively Lookup2 a 10 b 20 v 30 t 40 Lookup3 (12 Replies)
Discussion started by: ritakadm
12 Replies

4. UNIX for Dummies Questions & Answers

File joining and sorting

Hi, I'm having some trouble joining these two files for some reason. Here is what they look like: head * I'm using: join -a 1 -1 2 -2 1 f1 f2 -t, > joinfile.out but unfortunately nothing is happening. I did notice that I was having trouble sorting f1 and I'm not sure why using:... (6 Replies)
Discussion started by: verse123
6 Replies

5. Shell Programming and Scripting

Joining

I do have many files of the following format. File_1.txt 1 24 2 25 3 27 4 28 5 29 6 1 File_2.txt 2 5 3 8 4 9 5 10 File_3.txt (3 Replies)
Discussion started by: Lucky Ali
3 Replies

6. Shell Programming and Scripting

Changing exact matches with awk from subfields

To give you some context of my issue the following is some sample dummy data. The field delimiter is "<-->". The 4th field is going to be tags for my notes. The tags should always be unique and sorted alphabetically. 1<-->01/20/12<-->01/20/12<-->1st note<-->1st note<-NL->2 lines... (4 Replies)
Discussion started by: adamreiswig
4 Replies

7. Shell Programming and Scripting

Need help joining lines

Hi All, I need the command to join 2 lines into one. I found lots of threads but none give me the sollution. Probably because unix scripting is one of my best features ;) I got a logfile where line 2 needs to be joined with line 1, lines 4 needs to be joined with line 3 etc If you need... (16 Replies)
Discussion started by: rene21976
16 Replies

8. Shell Programming and Scripting

Joining of Commands.

Hello, i have a few questions which i hope you guys can address. the 1st prob: The database i am using is a text file which displays the information like this : Title : Quantity : Price Persia : 30 : 20 ... (5 Replies)
Discussion started by: gregarion
5 Replies

9. Shell Programming and Scripting

Transposing column to row, joining with another file, then sorting columns

Hello! I am very new to Linux and I do not know where to begin... I have a column with >64,000 elements (that are not in numberical order) like this: name 2 5 9 . . . 64,000 I would like to transpose this column into a row that will later become the header of a very large file... (2 Replies)
Discussion started by: doobedoo
2 Replies

10. UNIX for Dummies Questions & Answers

joining files

Hi, Could anyone help me ? I'm trying to join two files, but no common field are on them. So I think on generate \000\ sequence to add for each line on both files, so then will be able to join these files. Any idea? Thanks in advance, (2 Replies)
Discussion started by: Manu
2 Replies
Login or Register to Ask a Question