I have written a small script in Python to help me work with a large .csv
file, but I'm currently having a few issues...
In the main of the program it prompts the user for an input, then calls a function referring to those options, like so... (only showing option one):
def Main():
response = input('1, 2 or 3? ')
if response == 1:
ID = input('Enter your ID: ')
Response_one(ID)
This function Response_one
then opens the file, and I want it to search through and find where the ID
variable that the user entered is present in the .csv
, before printing that line. So far I have something like this:
def Response_one(ID):
file_csv = csv.DictReader(open('my_file.csv'))
for row in file_csv:
if row['ID'] == ID:
print row
I got to this point by following a few things online but I'm now stuck. I've been testing with IDs that I know exist within the table such as 'ENSG00000210049', but I get the error message:
NameError: name 'ENSG00000210049' is not defined
Any help would be hugely appreciated.