Accessing a URL file Remotely

Discussion in 'Python' started by mcl, Nov 29, 2007.

  1. mcl

    mcl Guest

    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
     
    mcl, Nov 29, 2007
    #1
    1. Advertising

  2. mcl

    TheSeeker Guest

    On Nov 29, 3:13 pm, mcl <> wrote:
    > 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
     
    TheSeeker, Nov 29, 2007
    #2
    1. Advertising

  3. mcl

    mcl Guest

    On 29 Nov, 22:32, TheSeeker <> wrote:
    > On Nov 29, 3:13 pm, mcl <> 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
     
    mcl, Nov 30, 2007
    #3
  4. On 2007-11-30, mcl <> wrote:

    > 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.

    --
    Grant Edwards grante Yow! I like the way ONLY
    at their mouths move ... They
    visi.com look like DYING OYSTERS
     
    Grant Edwards, Nov 30, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ike
    Replies:
    1
    Views:
    472
    Missaka Wijekoon
    Sep 12, 2003
  2. Replies:
    0
    Views:
    358
  3. Replies:
    5
    Views:
    461
    Brandon Gano
    Jul 23, 2007
  4. helveticus

    Remotely accessing SQL server DB

    helveticus, May 2, 2008, in forum: ASP .Net
    Replies:
    8
    Views:
    494
    Paul Shapiro
    May 3, 2008
  5. Slow Accessing Webservice Remotely

    , Aug 27, 2008, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    103
Loading...

Share This Page