finding a joint set between text file and csv file

Issue

This Content is from Stack Overflow. Question asked by Yair

trying to compare list of names from a text file, with a list of names from a csv file.

ive created a set of names from the text file using the following:

# receive text and create new list
with open('text.txt') as f:
    lines = f.readlines()
    names = []
    # add first 5 characters from lines to list to get name
    for x in lines[9:1011]:
        names.append(x[0:5])
        names.sort()
        # create set from list to eliminate duplicates
unique_name = set(names)
print(unique_name)

now id like to compare the set with a csv table with a name column and was wondering what the best way to do this is?
thank you



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?