Oct-21-2019, 10:44 AM
(Oct-20-2019, 02:32 PM)snippsat Wrote:ok in order to read or write that file i saved it as usstates.csv but i am getting this error .I think i have saved that file in the wrong location.In which directory i need to save that file? I am using python 3.7.4 shell.(Oct-20-2019, 10:33 AM)tahir1990 Wrote: ok got it all clear.But how to export that into CSV file?Show what you have tried.
If save to a list,then can eg use csv module.
import csv lst = ['Alabama', 'Alaska', 'Arizona'] with open('filename.csv', 'w') as myfile: wr = csv.writer(myfile) wr.writerow(lst)
Output:Alabama,Alaska,Arizona
Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> with open('usstates.csv', 'r') as csv_file: FileNotFoundError: [Errno 2] No such file or directory: 'usstates.csv'