Accessing a URL file Remotely

James Matthews nytrokiss at gmail.com
Fri Nov 30 06:44:11 EST 2007


Once you use urlopen you can read the website like a file

On Nov 30, 2007 10:58 AM, mcl <mcl.office at googlemail.com> wrote:

> On 29 Nov, 22:32, TheSeeker <duane.kauf... at gmail.com> wrote:
> > On Nov 29, 3:13 pm, mcl <mcl.off... at googlemail.com> wrote:
> >
> >
> >
> > > I have been given a url ofCSVfile (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 theCSVmodule to read that file, which I
> > > have successfully used with a localCSVfile.
> >
> > > 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
>
> Duane,
>
> Brilliant - I had fears of much more complication.
>
> Thank you very much
>
> Richard
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.goldwatches.com
http://www.jewelerslounge.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071130/4aabab56/attachment.html>


More information about the Python-list mailing list