Accessing a URL file Remotely

M

mcl

I have been given a url of CSV file (http://hostname/dir/file.csv),
which when I put the full URL in a web browser shows the contents of
the file.

I want to be able to use the CSV module to read that file, which I
have successfully used with a local CSV file.

Any examples anywhere would be appreciated.

My basic research suggests URLLIB, but I can not find a suitable
example.

I do not understand what additional information, needs to be given to
the remote site in order for it to expose the contents of the file as
though I was reading it locally.

Do I need to copy it to my local machine or can I read it directly
from the remote site.

As you can probably tell, I have never done anything like this, so any
help will be gratefully received.

Thanks

Richard
 
T

TheSeeker

I have been given a url of CSV file (http://hostname/dir/file.csv),
which when I put the full URL in a web browser shows the contents of
the file.

I want to be able to use the CSV module to read that file, which I
have successfully used with a local CSV file.

Any examples anywhere would be appreciated.

My basic research suggests URLLIB, but I can not find a suitable
example.

I do not understand what additional information, needs to be given to
the remote site in order for it to expose the contents of the file as
though I was reading it locally.

Do I need to copy it to my local machine or can I read it directly
from the remote site.

As you can probably tell, I have never done anything like this, so any
help will be gratefully received.

Thanks

Richard

-----untested------

import urllib, csv

fp_page = urllib.urlopen("http://URL_of_file")
reader = csv.reader(fp_page)
for row in reader:
print row

Duane
 
G

Grant Edwards

Brilliant - I had fears of much more complication.

I've been writing Python programs for almost 10 years, and I
still have that reaction not infrequently.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top