1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rookie JS question about fetching from CSV

Discussion in 'HTML & Website Design' started by JoeKerr99, Nov 29, 2021.

  1. #1
    I'm making a line graph and when I use:

    fetch('https://data.cdc.gov/resource/w9j2-ggv5.csv')

    everything works fine. When I download the csv file and try to read from my desktop I use:

    fetch('C:\Users\JoeKe\OneDrive\Desktop\w9j2-ggv5.csv')

    and it doesn't work.

    Can someone help please?!?
     
    JoeKerr99, Nov 29, 2021 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    There's a different syntax for local files. Get it by opening the csv file with chrome/edge/firefox and it'll show you how the path should be written
     
    sarahk, Nov 30, 2021 IP
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #3
    If you're trying to open it in the browser, change the backslashes to forward slashes. C:/Users/JoeKe/OneDrive/Desktop/w9j2-ggv5.csv
     
    qwikad.com, Nov 30, 2021 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #4
    but shouldn't it also be file://
     
    sarahk, Nov 30, 2021 IP
  5. Hooman Bahreini

    Hooman Bahreini Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    You cant access local filesystem using javascript. For accessing the file using javascript, you have to upload it on a server.

    See here for more info: https://stackoverflow.com/questions/20138001/reading-files-from-hard-drive-with-javascript
     
    Hooman Bahreini, Nov 30, 2021 IP