Sponsored Content
Full Discussion: Compare 2 csv files
Top Forums Shell Programming and Scripting Compare 2 csv files Post 303019852 by RudiC on Sunday 8th of July 2018 07:02:26 PM
Old 07-08-2018
Now, this (or very similar) problem has been solved umpteen times in here. Try
Code:
awk -F, '
function PRERR(VAR)     {print "Error: Mismatch in the record ", $0, ", field f" VAR ". Expected - ", FN[VAR, KEY], " actual - ", $VAR
                        }

                        {KEY = $1 SUBSEP $2
                        }

NR == FNR               {LN[KEY] = $0
                         for (i=3; i<=5; i++) FN[i, KEY] = $i
                         next
                        }

(KEY in LN)             {for (i=3; i<=5; i++) if (FN[i, KEY] != $i) PRERR(i)
                         delete LN[KEY]
                         next
                        }

                        {print "Error: There is no record ", $0, " in Expected."
                         delete LN[KEY]
                        }

END                     {for (l in LN) print "Error: There is no record ", LN[l], " in Actual."
                        }
 
' file[12]
Error: Mismatch in the record  1,a,33,44,55,999 , field f5. Expected -  56  actual -  55
Error: There is no record  4,d,90,12,56,888  in Expected.
Error: There is no record  4,x,90,12,56,333  in Actual.

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Compare 2 csv files in perl

need to compare 2 csv files and report should containg number of matching lines,different lines ,missing lines in one file using perl. I dont want to use read line by line and scan thru the second file for matching line ,as this logic was so time consuming .Any ideas.i need the soultion badly .... (2 Replies)
Discussion started by: kittu1979
2 Replies

2. UNIX for Dummies Questions & Answers

How to compare csv files using perl

I need to compare 2 csv files and report should containg number of matching lines,different lines ,missing lines in one file using perl. I dont want to use read line by line and scan thru the second file for matching line ,as this logic was so time consuming .Can other ideas .please respond asap... (2 Replies)
Discussion started by: kittu1979
2 Replies

3. Shell Programming and Scripting

Need to compare two csv files values and write into another csv file

Hi all, Am new to scripting. So i just need your ideas to help me out. Here goes my requirement. I have two csv files 1.csv 2.csv abc,1.24 abc,1 def,2.13 def,1 I need to compare the first column of 1.csv with 2.csv and if matches then need to compare... (2 Replies)
Discussion started by: chinnahyd
2 Replies

4. Shell Programming and Scripting

Need to compare values on two CSV files

:( Hello, Having a problem with reading two files using awk/nawk, am new to both them. I need to compare field values between two csv files and arrange for an appropriate output if both the values are equal or not for each feild. $cat File1.csv... (4 Replies)
Discussion started by: pgop
4 Replies

5. Shell Programming and Scripting

Help with script to open and compare csv files

We are testing an application that accesses two tables: A and B. I am to write a script to validate the ouput files of this application.The application marks any account that has become overdue as per rule. When it runs, it updates the overdue flag in the A table according to the following rules: ... (1 Reply)
Discussion started by: inkyponky
1 Replies

6. Shell Programming and Scripting

Need Perl script to compare two CSV files

Need perl script to compare the two CSV files and and give out put in CSV format File MsPMTP.csv File ProfileNames.csv MsPMTP.csv is having lines like below JBL_VIJ_A_A962/r01sr4sl12/port#01-#13-Au4P-4c-TMi-PMNETR15 JBL_VIJ_A_A962/r01sr4sl12/port#01-#13-Au4P-4c-TMi-PMFETR15... (9 Replies)
Discussion started by: sreedhargouda
9 Replies

7. Shell Programming and Scripting

How to compare the columns in two .csv files?

Hi I have to compare two .csv files which having 4 columns and i am expecting the output if there is difference in the 3,4columns in two files with respect to the first column. if my statement is not clear please refer the example. Input: ----- File 1 : hostname MAC SWITCH_IP SWITCH_PORT... (7 Replies)
Discussion started by: Kanchana
7 Replies

8. Shell Programming and Scripting

Compare 2 csv files in ksh and o/p the difference in 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 The... (7 Replies)
Discussion started by: Naresh101
7 Replies

9. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

10. Shell Programming and Scripting

Compare and merge two big CSV files

Hi all, i need help. I have two csv files with a huge amount of data. I need the first column of the first file, to be compared with the data of the second, to have at the end a file with the data not present in the second file. Example File1: (only one column) profile_id 57036226... (11 Replies)
Discussion started by: SirMannu
11 Replies
UPSLOG(8)							    NUT Manual								 UPSLOG(8)

NAME
upslog - UPS status logger SYNOPSIS
upslog -h upslog [OPTIONS] DESCRIPTION
upslog is a daemon that will poll a UPS at periodic intervals, fetch the variables that interest you, format them, and write them to a file. The default format string includes variables that are supported by many common UPS models. See the description below to make your own. OPTIONS
-h Display the help message. -f format Monitor the UPS using this format string. Be sure to enclose format in quotes so your shell doesn't split it up. Valid escapes within this string are: %% Insert a single "%" %TIME format% Insert the time with strftime formatting %ETIME% Insert the number of seconds, ala time_t. This is now a 10 digit number. %HOST% insert the local hostname %UPSHOST% insert the host of the UPS being monitored %PID% insert the pid of upslog %VAR varname% insert the value of variable varname The default format string is: %TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage% %VAR ups.load% [%VAR ups.status%] %VAR ups.temperature% %VAR input.frequency% -i interval Wait this many seconds between polls. This defaults to 30 seconds. If you require tighter timing, you should write your own logger using the upsclient(3) library. -l logfile Store the results in this file. You can use "-" for stdout, but upslog will remain in the foreground. -s ups Monitor this UPS. The format for this option is upsname[@hostname[:port]]. The default hostname is "localhost". -u username If started as root, upsmon will setuid(2) to the user id associated with username for security. If username is not defined, it will use the value that was compiled into the program. This defaults to "nobody", which is less than ideal. SERVICE DELAYS
The interval value is merely the number given to sleep(3) after running through the format string. Therefore, a query will actually take slightly longer than the interval, depending on the speed of your system. LOG ROTATION
upslog writes its PID to upslog.pid, and will reopen the log file if you send it a SIGHUP. This allows it to keep running when the log is rotated by an external program. SEE ALSO
Server: upsd(8) Clients: upsc(8), upscmd(8), upsrw(8), upsmon(8) Internet resources: The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ Network UPS Tools 05/21/2012 UPSLOG(8)
All times are GMT -4. The time now is 04:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy