Intro to Python CSV Processing for Actual Beginners
I've written quite a bit about CSV processing . It crops up in my books. A lot.
In all cases, though, I make the implicit assumption that my readers already know a lot of python. This is a disservice to anyone who's getting started.Getting Started
You'll need Python 3.6. Nothing else will do if you're starting out. Go here to find it.You can get the small "Miniconda" version to start with. It has some of what you'll need to hack around with CSV files. The full Anaconda version contains a mountain of cool stuff, but it's a big download.
Once you have Python installed, what next? To be sure things are running do this:Find a command line prompt (terminal window, cmd.exe, whatever it's called on your OS.) Enter python3.6 (or just python in windows.) If Anaconda installed everything properly, you'll have an interaction that looks like this: MacBookPro-SLott:Python2v3 slott$ python3.5 Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>>
More-or-less. (Yes, the example shows 3.5.1 even though I said you should get 3.6. As soon as the Lynda.com course drops, I'll upgrade. The differences between 3.5 and 3.6 are almost invisible.)
Here's your first interaction:>>> 355 / 113 3.1415929203539825 >>> 355 / 113 3.1415929203539825
Here's some more.>>> exit Use exit() or Ctrl - D(i.e.EOF) to exit >>> exit()
Okay. That was fun. But it's not data wrangling. When do we get to the good stuff?To Script or Not To Script
We have two paths when it comes to scripting. You can write script files and run them. This is pretty normal application development stuff. It works well. Or, you can use a Jupyter Notebook. This isn't exactly a script, but you can use it like a script. It's a good place to start building some code that's useful. You can rerun some (or all) of the notebook to make it script-like.
If you downloaded Anaconda, you have Jupyter. Done. Skip over the next part that covers installing Jupyter.Installing Jupyter
If you did not download the full Anaconda -- perhaps because you used the Miniconda -- you'll need to add Jupyter. You can use the 'conda command' installer for this.
Another choice is to use the PIP program to install Jupyter. The net effect is the same. It starts like this:MacBookPro-SLott:Python2v3 slott$ pip3 install jupyter Collecting jupyter Downloading jupyter-1.0.0-py2.py3-none-any.whl Collecting ipykernel (from jupyter) Downloading ipykernel-4.5.2-py2.py3-none-any.whl (98kB)
本文开发（python）相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程
本文标题：Intro to Python CSV Processing for Actual Beginners