FW: Reading a remove csv file
ROGER GRAYDON CHRISTMAN
dvl at psu.edu
Thu Nov 2 09:18:21 EDT 2017
I have a partial answer to my own question:
This seems to work for me:
---
link = urllib.request.urlopen(urlpath)
data = link.read().decode('utf-8').split('\n')
reader = csv.DictReader(data)
for row in reader:
---
I think here my concern is that now 'data' is now a variable
in my program's memory (all of the data),
instead of streamlike. I suppose I did read
somewhere about setting a stream option.
Roger Christman
Pennsylvania State University
---------------- Forwarded Message ----------------
Just a quick question on how best to read a remote CSV
file.
So far, I
tried:
filelink =
urllib.request.urlopen(path)
dictread =
csv.DictReader(filelink)
for row in
dictread:
...
But I'm running
into the difference between strings and bytes.
I'd
like to squeeze a note that talks about the utf-8
encoding,
but although I find that as an option for a
local file (with open())
I did not see that on my
first glance at the two functions
above.
Is there an easy way to read a
remove CSV file with utf-8 encoding
without copying
the whole file locally first?
Roger
Christman
Pennsylvania State University
More information about the Python-list
mailing list