Batch: 2 compare 2 files and merge

May 17, 2011 at 01:34:11
Specs: Windows XP, Intel core 2 DUO/ 2GB
Dear mates,

I have two files of CSV and would like to merge into one file with out exchanging info.

1st csv (or text file) has info in two columns. (i.e, file names, member revision 1)
2nd csv (or text file) has info in two columns. (i.e, file names, member revision 2)

I would like to have the 3rd CSV by merging/adding two files.

So that the output be in 3 columns,

o/p in CSV: file name; member name 1; member name 2
it should compare the file names of the of two files and if they repeat then take that file name in 1st column with member rev 1 in 2nd column and mem rev 2 in 3rd column.

&&& if they dont repeat the name then also take the file name and write in 1st column with repesctive mem revision.
i mean if thhis fil name is from 2nd file then it contains only mem rev 2,
So in the output file should be like file name in 1st column, 2nd column should be blank, 3rd column should fill with mem rev 2.

example:

I have 2 csv files with information.

1st: contains file names and versions.
COM; 1.1
CAD; 2.1
SAD; 3.1

2nd: contains file names and versions.
COM; 1.2
CAD; 2.2
MOD; 4.1

Putüput should be: file name; mem rev 1; mem rev 2 (in 1st, 2nd & 3r columns in CSV file)
COM 1.1 1.2
CAD 2.1 2.2
SAD 3.1 --
MOD -- 4.1


Please help me. its very urgent, it can save my job.
I am sorry if i couldnt give you ppl much info.

Thanks in advance


See More: Batch: 2 compare 2 files and merge

Report •


#1
May 17, 2011 at 06:52:57
This is essentially a repeat of your post of May 11. I don't think a batch is the best method of solving the problem. Also, why is CAD after COM, if the lists are not in the same order and the versions in list 2 is earlier than list 1. Also you are now using fill for those which do not occur. Another possibllity is having the same program with different versions on the same list.

Report •

#2
May 17, 2011 at 07:29:47
Hallo Fred,

Greetings,

Sorry for the re-post,
I just thought that I could expalin better in this Post.

Well i have two input files which i have extracted from the Project by using MKS tool.

Now my job is to compare the files and sort them. and have to do only in Batch.

my i/p file looks like: {path with file name; revision number}

COM\addcompileropts.def 1.2
COM\bus_conf.h 1.8.5
COM\can_application.c 1.6.2
DCA\addcompileropts.def 1.1
DCA\dccd.grl 1.1.12
DDS\DDS_D4P\@Ecu.grl 1.7.1
DDS\DDS_D4P\central.grl 1.2
DDS\DDS_GENERIC\@conversions.grl 1.3.1
DDS\DDS_GENERIC\@Raster.grl 1.2.1
DIA\app_data.c 1.3.1.1
EMA\addcompileropts.def 1.2.13.1
EMA\link.lnk 1.1.21.3

Both i/p files have almost the same file names but revisions might be same or different.
& some times the 1st i/p file many have some files which do not exist in the 2nd i/p file.

So the output file should take it and read but should fille the column only in 1st.

I hope you understand what i need.
Sorry if i am not clear.

Please lemme know if need any further info i will try in better way.

Thnx for your time n patience.


Report •

#3
May 17, 2011 at 07:33:31
Sorry for the worng line:

**So the output file should take it and read but should fille the column only in 1st.**

its clear in example @ starting post:

COM 1.1 1.2
CAD 2.1 2.2
SAD 3.1 --
MOD -- 4.1
------------------------------------------


Report •

Related Solutions

#4
May 18, 2011 at 02:01:39
The file names are in Alphebetic order...!!!!

Sorry for the example, it shoulde be:
---------------------------------------------
CAD 2.1 2.2
COM 1.1 1.2
MOD -- 4.1
SAD 3.1 --
-----------------------------------------
I hope now its bit clear..!!!

Please help me out...!!!

Thank you..!!!



Report •


Ask Question