Project

General

Profile

« Previous | Next » 

Revision 4662

cols: Support CSVs without a header, such as intermediates that become unmapped_terms.csv, new_terms.csv

View differences:

bin/cols
1 1
#!/usr/bin/env python
2 2
# Selects columns from a spreadsheet
3
# CSVs without a header are supported.
3 4

  
4 5
import csv
5 6
import os.path
......
20 21
    reader = csv.reader(sys.stdin)
21 22
    writer = csv.writer(sys.stdout)
22 23
    def subset(row): return util.list_subset(row, col_nums)
23
    writer.writerow(subset(reader.next()))
24 24
    for row in reader: writer.writerow(subset(row))
25 25

  
26 26
main()

Also available in: Unified diff