I have two files with lots of columns and different information about a bunch of objects, that come with object IDs. I need to find matches between the two files, but the object IDs come in two different formats:
12-12-1 in one file will be written as 0012 00012 1 in the other. For instance, in one file I have:
0001 01531 1
0001 01535 1
0001 01538 1
Which corresponds to this in the other:
1-1531-1
1-1535-1
1-1538-1
Something as simple as
matches = open('matches.dat','w')
for j in range(len(file1)):
for i in range(len(file2)):
if file1[j] == file2[i]:
matches.write('{}/n'.format(file1[j]))
doesn't seem to do the trick.
file1 and file2 here are lists that contain all the object IDs from the different files.
What do I add to my code to find the matches?