Storm Tracker
Storm Tracker

Reputation: 39

Import error: No module named gspread or csv?

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

Answers (2)

CMDoolittle
CMDoolittle

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

elyase
elyase

Reputation: 40973

Try the following:

  1. Check you don't have a file named csv.py

  2. Check you have python version >= 2.3

  3. Install gspread with:

    pip install gspread

Upvotes: 6

Related Questions