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

More Query from same tag