Hi all,
I'm try to write a code to search strings (from one textfile with lists of strings) in second large text file.
but script doesn't search my lists in entire file (not complete output file)

*[list_life.txt]*
1654
964563
41164
6165456
85248
999745
35496486
... +2000 row's

*[large_file.txt]
*1654    2017/02/02
666445    2017/02/02
964563    2017/02/02
41164    2017/02/02
2467924    2017/02/02
6165456    2017/02/02
1145    2017/01/02
85248    2017/01/02
3354110    2017/01/02
999745    2017/01/02
8778873    2017/01/02
35496486    2017/01/02
666564646    2017/01/02
... + 500000 rows

*[code]*
file_list = open("list_life.txt")
file_large = open("large_file.txt")
save_file = open('output.txt', 'w')

for line_list in file_list:
    splitted_line_list = line_list.split()
    for line_large in file_large:
        splitted_line_large = line_large.split()
        if splitted_line_large[0] == splitted_line_list[0]:
            save_file.write(line_large+"\n")

file_large.close()
file_list.close()

*
*
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to