Sponsored Content
Top Forums Shell Programming and Scripting Compare 2 files of csv file and match column data and create a new csv file of them Post 302938880 by refrain on Thursday 19th of March 2015 05:27:41 PM
Old 03-19-2015
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:
Code:
SourceFile,DateTimeOriginal
/home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07
/home/intannf/foto/IMG_0677.JPG,2015:02:17 10:47:23
/home/intannf/foto/IMG_0739.JPG,2015:02:17 11:32:21
/home/intannf/foto/IMG_0749.JPG,2015:02:17 11:37:28
/home/intannf/foto/IMG_0759.JPG,2015:02:17 11:49:09
/home/intannf/foto/IMG_0689.JPG,2015:02:17 10:57:05
/home/intannf/foto/IMG_0709.JPG,2015:02:17 11:13:31
/home/intannf/foto/IMG_0771.JPG,2015:02:17 11:51:22
/home/intannf/foto/IMG_0766.JPG,2015:02:17 11:50:08
/home/intannf/foto/IMG_0745.JPG,2015:02:17 11:36:01

File2:
Code:
2015/02/17,01:56:53,0.,-7.77075,110.35782,6.38 
2015/02/17,10:47:23,0.,-7.77075,110.35782,6.34 
2015/02/17,11:49:09,0.,-7.77075,110.35782,6.31 
2015/02/17,11:49:53,0.,-7.77075,110.35782,6.25 
2015/02/17,11:51:22,0.,-7.77075,110.35782,6.20 
2015/02/17,11:53:25,0.,-7.77075,110.35782,6.19 
2015/02/17,11:55:11,0.,-7.77075,110.35782,6.19 
2015/02/17,11:56:35,0.,-7.77075,110.35782,6.80

Output required:
Code:
SourceFile,AirSpeed,GPSLatitude,GPSLongitude,Altitude
/home/intannf/foto/IMG_0677.JPG,0.,-7.77075,110.35782,6.34 
/home/intannf/foto/IMG_0759.JPG,0.,-7.77075,110.35782,6.31 
/home/intannf/foto/IMG_0771.JPG,0.,-7.77075,110.35782,6.20

Note:
The matched columns of both files are not written in the 'new' csv file i want to create.
In the file1, it has header file, while file2 doesn't have any header file. But, in the new csv file (output required), I want to create header file of each column.
and also, time and date of file1 is in same column (one column and separated by space), while time and date of file2 is in different different column (separated by comma).

Would you help me how to solve it? I am not sure how the shell script would be. But I am still learning. I really need your help. Sorry for my bad english, I hope you understand what I mean. Thank you.

Regards,
Intan

Last edited by vgersh99; 03-19-2015 at 06:49 PM..
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

3. Shell Programming and Scripting

Merge CSV files and create a column with the filename from the original file

Hello everyone!! I am not completely new to shell script but I havent been able to find the answer to my problem and I'm sure there are some smart brains here up for the challenge :D. I have several CSV files that I need to combine into one, but I also need to know where each row came from.... (7 Replies)
Discussion started by: fransanchezoria
7 Replies

4. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

5. 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

6. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

7. Shell Programming and Scripting

How to separate data coming in one column of CSV file?

I am running an ISQL command on Sybase DB and getting output of a query in an CSV file. The issue is that all the data comes in to the same column, i want them to be separated in different columns. SQL_COMMAND=command.sql file=file.txt formatFile=formatFile.txt report=report.csv echo... (1 Reply)
Discussion started by: Sharma331
1 Replies

8. Shell Programming and Scripting

Matching two fields in two csv files, create new file and append match

I am trying to parse two csv files and make a match in one column then print the entire file to a new file and append an additional column that gives description from the match to the new file. If a match is not made, I would like to add "NA" to the end of the file Command that Ive been using... (6 Replies)
Discussion started by: dis0wned
6 Replies

9. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies

10. UNIX for Beginners Questions & Answers

Compare every column from one csv file to another csv file

1.csv contains following column- Empid code loc port 101 A xy 01 102 B zx 78 103 A cg 12 104 G xy 78 2.csv contains follwing data- Empid code loc port 101 A gf 01 102 B zx 78 103 C cg 32 104 ... (1 Reply)
Discussion started by: rishabh
1 Replies
.::SWF::Bitmap(3pm)					User Contributed Perl Documentation				       .::SWF::Bitmap(3pm)

NAME
SWF::Bitmap - Bitmap class SYNOPSIS
use SWF::Bitmap; $bitmap = new SWF::Bitmap('filename'); $fill = $shape->addBitmapFill($bitmap); DESCRIPTION
SWF::Bitmap enables you to add JPG, PNG, GIF and DBL files. It is a helper class most useful for filling shapes (i.e. SWF::Shape objects). DBL files ('Define Bitmap Lossless') may be produced from PNG or GIF files by using png2dbl or gif2dbl tools. METHODS
$bitmap = new SWF::Bitmap($filename, [$alpha]) Creates a new SWF::Bitmap object using 'filename'. The alpha parameter represents a filename for opacity data ('alpha' channel), but only for JPG files. Alpha data files are produced by tool gif2mask. The original GIF used for gif2mask input file containing alpha information should have same dimensions (width x height) as the JPG file. $bitmap = newBitmapFromFileHandle($filehandle) Creates a new SWF::Bitmap object using an open file handle $filehandle . This way you could use STDIN, piped data etc. etc. for input. A simple example: open (PICT,'flowers.jpg') or die; $bmp = newBitmapFromFileHandle SWF::Bitmap(PICT); # ..... $m->save("my_flowers.swf"); close (PICT); # Please note: do not close the PICT file too early. $bitmap = newSWFDBLBitmap SWF::Bitmap($filename) Creates a new SWF::Bitmap object using DBL file. Use this constructor if you have a file with DBL data, but not with .dbl filename extension. $bitmap = newSWFJpegBitmap SWF::Bitmap($filename) Creates a new SWF::Bitmap object using JPG file. Use this constructor if you have a file with JPG data, but not with .jpg or .jpeg filename extension. $bitmap = newSWFJpegWithAlpha SWF::Bitmap($filename,$alpha_filename) Creates a new SWF::Bitmap object using JPG file similar newSWFJpegBitmap() with additional opacity information in 'alpha' file. Use this constructor if you have a file with JPG data, but not with .jpg or .jpeg filename extension and if there is opacity information available in 'alpha_filename' file. Alpha data files are produced by gif2mask tool. The original GIF file containing alpha information used for gif2mask input should have same dimensions as the JPG file. $width = $bitmap->getWidth(); Returns width of bitmap in pixels. $height = $bitmap->getHeight(); Returns height of bitmap in pixels. AUTHOR
Soheil Seyfaie (soheil@netcom.ca), Albrecht Kleine and developers of ming.sourceforge.net SEE ALSO
SWF, SWF::Fill, SWF::Shape, SWF::Button, SWF::Constants, png2dbl, gif2dbl, gif2mask perl v5.14.2 2011-10-26 .::SWF::Bitmap(3pm)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy