Read data from a csv file
Posted: Fri May 05, 2017 9:51 pm
I have successfully created many .csv files and been able to load them into a spreadsheet.
I have now created another .csv file that contains just one number.
I just need to be able to read the number back in another program and place it in the variable 'detect'.
I have tried using the following code (and many variations on it), without success.
Could someone please advise where I am going wrong.
Thanks.
I have now created another .csv file that contains just one number.
I just need to be able to read the number back in another program and place it in the variable 'detect'.
I have tried using the following code (and many variations on it), without success.
Code: Select all
detect =0
file = open('my_file.csv', 'r')
detect = file.read ()
file.close()
print ('detect')Thanks.