score:2

use firefox, idk what chrome tries to accomplish

score:4

also, just learning d3 for school work. i was trying to run this simple d3 example: https://gist.github.com/d3noob/b3ff6ae1c120eea654b5

i had the same problem as op re: loading data using chrome browser. i bet the great solution hillary sanders posted above was re: python 2.x.

my answer is re: python 3.x [os: ubuntu 16x]:

open a terminal window within the root directory of your project, then run:

python3 -m http.server

it will serve http on port 8000 by default unless it is already taken, in that case to open another port, e.g. 7800, run:

python3 -m http.server 7800

then, on your chrome browser address bar type:

localhost:8000

the above worked for me because i only had an index.html page in my root folder. in case, you have a html page with a different name, type the whole path to that local html page and it should work also. and, you should be able to see the graph created from the data set in my link (that must be in a folder like data/data.csv). i hope this helps. :-)

score:6

to those using built-in python webserver and who are still experiencing issues, do remember and make sure that you run the "python -m simplehttpserver 8888" invocation at the correct path of which you consider to be your documentroot. that is, you cannot just run 'python -m simplehttpserver 8888' anywhere. you have to actually 'cd /to/correct/path/' containing your index.html or data.tsv and then from there run 'python -m simplehttpserver 8888'.

score:34

this confused me too (i am also a d3 beginner).

so, for some reason, web browsers are not happy about you loading local data, probably for security reasons or something. anyways, to get around this, you have to run a local web server. this is easy.

in your terminal, after cd-ing to your website's document root (thanks @daixtr), type:

python -m simplehttpserver 8888 &

okay, now as long as that terminal window is open and running, your local 8888 web server will be running.

so in my case, originally the web page i was working on was called

file://localhost/users/hills/desktop/website/visualizing-us-bls-data-inflation-and-prices.html

when i opened it in chrome. to open up my page on my local web server, i just typed (into the chrome search bar):

http://localhost:8888/desktop/website/visualizing-us-bls-data-inflation-and-prices.html

now, reading in csvs should work. weird, i know.


Related Query