Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk assistance - Comparing 2 csv files Post 303019727 by tirmUK on Wednesday 4th of July 2018 04:49:17 PM
Old 07-04-2018
Thank you for the replies. Let me put some more clarify around the request, as suggested, as I'm not sure the awk suggestions are working.

First here is the csv, that contains the list of GUIDS:

Code:
$ cat test.csv
8121E002-96FE-4C9C-BC5A-6AFF20DACECD
84468F30-F3B7-418B-81F0-0908E80792BF
8121E002-96FE-4C9C-BC5A-6AFF20DACECD
1BCE1E40-D1BE-4DC1-8A0C-9EB236F56944

Now, here is an example of the csv that contains the data I'm trying to retrieve:

Code:
"test","data/content/FN0/FN0/FN0/170535BB-A28D-42C4-92ED-767BB1469C8D%7BC0348F5A-0000-C624-9710-5ED2E8AA2B14%7D0"
"test","data/content/FN0/FN0/FN0/17ECDCFA-AF30-4C82-A156-99F941739352%7B1373E3F5-D5BE-475B-900F-B73ECB05C6AB%7D0"
"test","data/content/FN0/FN0/FN0/182FECB0-ADBF-4F27-9DD6-CE5508872AA5%7BC88C4971-F16A-4C28-9E14-07D0AD4E3C79%7D0"
"test","data/content/FN0/FN0/FN0/194D4F16-CD21-46EF-A584-8C378FBAD55F%7B439BC63F-C291-479D-BFEC-121BC86E3988%7D0"
"test","data/content/FN0/FN0/FN0/1AD46B75-8357-421D-A072-64872C6C763C%7BF299763B-D507-4303-A819-00BD0C60AAA5%7D0"
"test","data/content/FN0/FN0/FN0/1B810336-4EA7-49E3-8325-69487AC0CE95%7BD2F0EDEA-1486-451C-A09C-9AC39D582BBF%7D0"
"test","data/content/FN0/FN0/FN0/1BA93974-FFCC-4BE2-AFBE-11B92D579D4B%7B805AFF56-0000-CC14-9F56-C335802C5C15%7D0"
"test","data/content/FN0/FN0/FN0/1BBC8C9A-725B-428D-AC5A-9C0129C80F82%7BE515FB66-D51E-4057-97C8-94CDEC52F83A%7D0"
"test","data/content/FN0/FN0/FN0/1BCE1E40-D1BE-4DC1-8A0C-9EB236F56944%7B496DDE3B-6102-4744-80FA-C30D64D91815%7D0"


As you can see, 1BCE1E40-D1BE-4DC1-8A0C-9EB236F56944 is in both the first csv and the 2nd csv. The last line of the 2nd csv it is embedded into a double GUID. I want the output to be:

Code:
1BCE1E40-D1BE-4DC1-8A0C-9EB236F56944, "data/content/FN0/FN0/FN0/1BCE1E40-D1BE-4DC1-8A0C-9EB236F56944%7B496DDE3B-6102-4744-80FA-C30D64D91815%7D0"

I tried the following suggestion:

Code:
awk -F "," 'BEGIN{OFS=FS}NR==FNR{q=$1;$1="";A[q]=$0;;next} {q=$2;gsub(/.*\/|\..*/,"",$2)} ($2 in A) {print $2,q}' test.csv file2.csv

But it did not find the above GUID.

RudiC, for your suggestion, where do I pass in the first filename?

Hopefully that helps!

Regards

Tirm

Last edited by Don Cragun; 07-04-2018 at 10:15 PM.. Reason: Add missing CODE tags, again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Last field problem while comparing two csv files

Hi All, I've two .csv files as below file1.csv abc, tdf, 223, tpx jgsd, tex, 342, rpy a, jdjdsd, 423, djfkld Where as file2.csv is the new version of file1.csv with some added fields in the end of each line and some additional lines. lfj, eru, 98, jkldj, 39, jdkj9 abc, tdf, 223, tpx,... (3 Replies)
Discussion started by: ganapati
3 Replies

2. Shell Programming and Scripting

Comparing 2 csv files and matching content

Hello, I have the following problem: There are two csv files csv-file #1: aaa1, aaa2, ... aaan aaa1, bbb2, ... bbbn aaa1, ccc2, ... cccn bbb1, bbb2, ... bbbn ... zzz1, zzz2, ... zzzn csv-file #2: aaa1, matchvalue1 ccc1, matchvalue2 (7 Replies)
Discussion started by: ghl10000
7 Replies

3. Shell Programming and Scripting

Comparing Strings in 2 .csv/txt files?

EDIT: My problems have been solved thanks to the help of bartus11 and pravin27 This code is just to help me learn. It serves no purpose other than that. Here's a sample csv that I'm working with - #listofpeeps.csv Jackie Chan,1954,M Chuck Norris,1930,M Bruce Lee,1940,M This code is... (13 Replies)
Discussion started by: chickeneaterguy
13 Replies

4. Shell Programming and Scripting

comparing csv files

Hi! I'm just new to shell scripting n simple tasks looks so tough in initial stage. i need to write a script which will read a property file, property file will be containing count of the csv files, and in a folder(same folder) there will be respective csv files. like Property file data1=100... (3 Replies)
Discussion started by: sukhdip
3 Replies

5. Shell Programming and Scripting

removing duplicate records comparing 2 csv files

Hi All, I want to remove the rows from File1.csv by comparing a column/field in the File2.csv. If both columns matches then I want that row to be deleted from File1 using shell script(awk). Here is an example on what I need. File1.csv: RAJAK,ACTIVE,1 VIJAY,ACTIVE,2 TAHA,ACTIVE,3... (6 Replies)
Discussion started by: rajak.net
6 Replies

6. Shell Programming and Scripting

Comparing two csv file fields using awk script

Hi All, I want to remove the rows from File1.csv by comparing the columns/fields in the File2.csv. I only need the records whose first column is same and the second column is different for the same record in both files.Here is an example on what I need. File1.csv: RAJAK|ACTIVE|1... (2 Replies)
Discussion started by: rajak.net
2 Replies

7. Shell Programming and Scripting

Comparing 2 difference csv files

Hello, I have about 10 csv files which range from csv1 - csv10. Each csv file has same type/set of tabs and we have around 5-6 tabs for each of the csv file which have slightly different content(data). A sample of CSV1 is shown below: Joins: Data related to Joins, it can be any number of... (2 Replies)
Discussion started by: bobby1015
2 Replies

8. Shell Programming and Scripting

Comparing 2 CSV files and sending the difference to a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 ... (1 Reply)
Discussion started by: Naresh101
1 Replies

9. Shell Programming and Scripting

Comparing two large unsorted csv files

Hi All, My requirement is to write a shell script to compare two large csv files. I've created sample files for explaining my problem i.e., a.csv and b.csv contents of files: ----------------- a.csv ------ Type,Memory (Kb),Location HD,Size (Mb),Serial # XT,640,D402,0,MG0010... (2 Replies)
Discussion started by: vasavi
2 Replies

10. Shell Programming and Scripting

Comparing two CSV files

I have two csv files and im trying to compare them. e.g. SAMPLE DATA: file one: ZipCode Name 20878 Washington 10023 Missouri 20304 Maryland file two: ID Name City ZipCode 11654 ... (11 Replies)
Discussion started by: dan139
11 Replies
mlib_SignalLimit(3MLIB) 				    mediaLib Library Functions					   mlib_SignalLimit(3MLIB)

NAME
mlib_SignalLimit, mlib_SignalLimit_S16_S16, mlib_SignalLimit_S16S_S16S, mlib_SignalLimit_S16, mlib_SignalLimit_S16S, mlib_Signal- Limit_F32_F32, mlib_SignalLimit_F32S_F32S, mlib_SignalLimit_F32, mlib_SignalLimit_F32S - signal hard limiting SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_SignalLimit_S16_S16(mlib_s16 *dst, const mlib_s16 *src, const mlib_s16 *low, const mlib_s16 *high, mlib_s32 n); mlib_status mlib_SignalLimit_S16S_S16S(mlib_s16 *dst, const mlib_s16 *src, const mlib_s16 *low, const mlib_s16 *high, mlib_s32 n); mlib_status mlib_SignalLimit_S16(mlib_s16 *srcdst, const mlib_s16 *low, const mlib_s16 *high, mlib_s32 n); mlib_status mlib_SignalLimit_S16S(mlib_s16 *srcdst, const mlib_s16 *low, const mlib_s16 *high, mlib_s32 n); mlib_status mlib_SignalLimit_F32_F32(mlib_f32 *dst, const mlib_f32 *src, const mlib_f32 *low, const mlib_f32 *high, mlib_s32 n); mlib_status mlib_SignalLimit_F32S_F32S(mlib_f32 *dst, const mlib_f32 *src, const mlib_f32 *low, const mlib_f32 *high, mlib_s32 n); mlib_status mlib_SignalLimit_F32(mlib_f32 *srcdst, const mlib_f32 *low, const mlib_f32 *high, mlib_s32 n); mlib_status mlib_SignalLimit_F32S(mlib_f32 *srcdst, const mlib_f32 *low, const mlib_f32 *high, mlib_s32 n); DESCRIPTION
Each of these functions performs hard limiting. For monaural signals, the following equation is used: dst[i] = low[0] if src[i] < low[0] dst[i] = src[i] if low[0] <= src[i] < high[0] dst[i] = high[0] if src[i] >= high[0] where i = 0, 1, ..., (n - 1). For stereo signals, the following equation is used: dst[2*i] = low[0] if src[2*i] < low[0] dst[2*i] = src[2*i] if low[0] <= src[2*i] < high[0] dst[2*i] = high[0] if src[2*i] >= high[0] dst[2*i+1] = low[1] if src[2*i+1] < low[1] dst[2*i+1] = src[2*i+1] if low[1] <= src[2*i+1] < high[1] dst[2*i+1] = high[1] if src[2*i+1] >= high[1] where i = 0, 1, ..., (n - 1). PARAMETERS
Each of the functions takes some of the following arguments: dst Destination signal array. src Source signal array. srcdst Source and destination signal array. low Lower input limit. In the stereo version, low[0] contains the lower limit for channel 0, and low[1] contains the lower limit for channel 1. high Upper input limit. In the stereo version. high[0] contains the upper limit for channel 0, and high[1] contains the upper limit for channel 1. n Number of samples in the source signal array. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.11 2 Mar 2007 mlib_SignalLimit(3MLIB)
All times are GMT -4. The time now is 11:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy