how to match row names of two files quickly using python

0

Now I have two files, file1 has a column of names as shown below(billions of lines):
"""
name1
name2
name3
name4
"""
file2 also has the column of names and some other information(not all names in file1 show up in file2, but all names in file2 show up in file1):
file2 like this:
"""
name1 18
name4 90
"""
Now I want to fill file1 with the second column of file2, if the name is not in file2, then fill 0 in that row in file1, the result should be like this:
"""
name1 18
name2 0
name3 0
name4 90
"""
Because there are billions of lines in each file, is there any way to do this very quickly? Thanks!


python


pandas


algorithm


file

• 16 views



Source link