Popular recipes tagged "cut"http://code.activestate.com/recipes/tags/cut/2011-02-02T21:39:45-08:00ActiveState Code RecipesFiltering CSV data by fields (cut for csv) (Python)
2011-02-02T21:39:45-08:00James Millshttp://code.activestate.com/recipes/users/4167757/http://code.activestate.com/recipes/577560-filtering-csv-data-by-fields-cut-for-csv/
<p style="color: grey">
Python
recipe 577560
by <a href="/recipes/users/4167757/">James Mills</a>
(<a href="/recipes/tags/csv/">csv</a>, <a href="/recipes/tags/cut/">cut</a>, <a href="/recipes/tags/data/">data</a>, <a href="/recipes/tags/filter/">filter</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Ever wanted to take a CSV file as input, cut it up
and only extract the fields that you want ?</p>
<p>Here's how!</p>
<p>$ cat cars.csv
Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38</p>
<p>$ csvcut.py -f 0 -f -1 - < cars.csv
Year,Length
1997,2.34
2000,2.38</p>
<p>--JamesMills (prologic)</p>