I’m following a tutorial on creating a chlerograph map using python.
The tutorial is here: http://flowingdata.com/2009/11/12/how-to-make-a-us-county-thematic-map-using-free-tools/
Following the instructions I have created a directory with:
- An svg xml map
- A csv file with data
- A python script “colorize_svg.py” with cut and pasted code from the tutorial.
- A downloaded script library folder called “beautiful soup” (actual folder name “beautifulsoup4-4.1.3”)
Everything seems straight forward enough, even if I have little coding experience and none with Python. Except step 14 “Now all we have to do is run our script and save the output” The author is referring to the terminal on the Mac. In any coding I have done previously it’s always been a case of opening a file, say an html file, with a browser to see the output.
This threw me off. How do I see my output using the terminal? Never used the terminal before? Must I somehow “link” the terminal to the “colorize.py” file? How? I tried just entering the files path into the terminal and hitting enter but got the attached image
You can just run it with the python command:
python /users/gcameron/Desktop/map/colorize_svg.pyIf you just run
pythonit will open the python console where you are able to run python code. This is good for testing small things, functions and similar stuff. Mostly I use it as a calculator though.In your python script, you can also define that it is a python script by (at the top of the document) type
#! /bin/python. Or if you have python installed elsewhere just type#! /path/to/python. If you do this, you just need to execute type the path to the script:/users/gcameron/Desktop/map/colorize_svg.pyand it will execute the python script with the python interpreter.