Reading and writing CSV/TSV files with Python
CSV and TSV formats are essentially text files formatted in a specific way: the former one separates data using a comma and the latter uses tab \t
characters. Thanks to this, they are really portable and facilitate the ease of sharing data between various platforms.
Getting ready
To execute this recipe, you will need the pandas
module installed. These modules are all available in the Anaconda distribution of Python and no further work is required if you already use this distribution. Otherwise, you will need to install pandas
and make sure that it loads properly.
Note
You can download Anaconda from http://docs.continuum.io/anaconda/install. If you already have Python installed but do not have pandas
, you ...
Get Practical Data Analysis Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.