Reputation: 39
I am working with a Google spreadsheet, and am trying to use Python 2.7 to convert the spreadsheet data to a CSV file.
When I attempt to run the script I receive:
Import error: No module named gspread.
When I take out the gspread
portion, then I receive:
Import error: No module named csv.
Any suggestions would be greatly appreciated. Thank you in advance.
import csv
import gspread
g=gspread.login('[email protected]', 'e-mail_password')
docid = "0AgNp9UJ4CX93dHl3RW9GRXJDS3kxaXRJMGNqWmhQWVE"
spreadsheet = g.open_by_key(docid)
for i, worksheet in enumerate(spreadsheet.worksheets()):
filename = docid + '-worksheet' + str(i) + '.csv'
writer = csv.writer(open(filename, 'wb'))
writer.writerows(worksheet.get_all_values())
Upvotes: 3
Views: 14629
Reputation: 299
Let's get some clarification here... the "pip install gspread" command is only for linux.
If you are on Windows, you need to have these modules in C:\Python27\Lib\site-packages
I thought CSV module came built-in but I checked and I don't have gspread, you need to download it and place the gspread.py file in the aforementioned directory.
Upvotes: 0
Reputation: 40973
Try the following:
Check you don't have a file named csv.py
Check you have python version >= 2.3
Install gspread with:
pip install gspread
Upvotes: 6