Reputation: 33
I am working through the store locator Google Maps tutorial. However I am having an error trying to import my own data. I am converting a csv file to GEOJSON. However I notice that when I do convert the 'storeid' value appears to be an integer and not a string.
The function I am sharing takes a geocoded file I have and creates a new csv file with a storeid attribute... however once again it is not a string... Here is my code
with open('geocodedchurches.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
with open('geocodedwithid.csv', 'w', newline='') as f:
thewriter = csv.writer(f)
thewriter.writerow(['storeid','email', 'contact_name', 'church_name', 'church_address', 'lat', 'lng'])
next(csv_reader)
ind = 1
for index, i in enumerate(csv_reader):
id = str(ind)
thewriter.writerow([id, i[0], i[1], i[2], i[3], i[4], i[5]])
ind = ind + 1
print(id,i)
Upvotes: 0
Views: 46
Reputation: 59184
The CSV format has no notion of data types. Quotes can be omitted if they are not necessary.
That being said, if you want to force quotes, you can use the following:
thewriter = csv.writer(f, quoting=csv.QUOTE_ALL)
Upvotes: 1