David Rinck
David Rinck

Reputation: 6986

Receiving email with .csv attachment with google app engine

I have been able to read emails, and I can see the attachments, but they don't come in as .csv data. I guess it is an 'EncodedPayload' type?

The following code:

for filename, content in attachments:
    logging.info("filename: " + filename)
    fileReader = csv.reader(content.split("\n"))

gave me this error:

'EncodedPayload' object has no attribute 'split'

How do I parse a csv file given an EncodedPayload ?

Upvotes: 0

Views: 540

Answers (1)

Chris Farmiloe
Chris Farmiloe

Reputation: 14175

call decode() on your content:

fileReader = csv.reader(content.decode())

Upvotes: 1

Related Questions