[python #SXM-109553]: latest obs to CSV?
- Subject: [python #SXM-109553]: latest obs to CSV?
- Date: Mon, 19 Nov 2018 13:48:25 -0700
So what error message is complaining about is that youâre trying to write a
`str` (text), but the file is expecting to be given `bytes` (binary data) to
write. In this case I think you *should* be writing text so you should change
your open line to:
with open("C:\\Users\\Public\\Documents\\outfile.csv", 'w') as outcsv:
Note the change from âwbâ to âwâ, which changes from opening the file
for binary i/o to text i/o. I expect that change should get you working.
Hope it helps!
> Hi Ryan,
> The error that I get when trying to output the station temp data is the
> TypeError Traceback (most recent call last)
> <ipython-input-5-9ded64172cc7> in <module>
> 1 with open("C:\\Users\\Public\\Documents\\outfile.csv", 'wb') as outcsv:
> 2 writer = csv.writer(outcsv,delimiter=',')
> ----> 3 writer.writerow(["lat", "long", "temp", "station"])
> 4 for i in data:
> 5 writer.writerow(i)
> TypeError: a bytes-like object is required, not 'str'
> Here is an example of how the data looks:
> (42.36056, -71.01056, 41.0, 'KBOS')
> Again, thank you for your time/any help!
> -----Original Message-----
> From: Unidata Python Support [mailto:address@hidden
> Sent: Monday, November 12, 2018 4:22 PM
> To: Perry, Justin B
> Cc: address@hidden
> Subject: [python #SXM-109553]: latest obs to CSV?
> No worries! What's the actual error message you receive?
> > Hi again,
> > The error that I was receiving yesterday seems to have resolved somehow. I
> > apologize!
> > However, I am still having a slight issue with the next step after that. I
> > am trying to write the Lat, Lon, Temp, Station ID to a CSV file and I keep
> > getting an error.
> > I'm essentially trying to take the data from the surface temp map and just
> > create a list of the data as well.
Ticket ID: SXM-109553
Department: Support Python
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.