Revision 1388
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/csvs.py | ||
---|---|---|
1 |
# CSV I/O |
|
2 |
|
|
3 |
import csv |
|
4 |
import StringIO |
|
5 |
|
|
6 |
def reader_and_header(stream): |
|
7 |
'''Automatically detects the dialect based on the header line |
|
8 |
@return tuple (reader, header)''' |
|
9 |
header_line = stream.readline() |
|
10 |
dialect = csv.Sniffer().sniff(header_line) |
|
11 |
header = csv.reader(StringIO.StringIO(header_line), dialect).next() |
|
12 |
return (csv.reader(stream, dialect), header) |
Also available in: Unified diff
Added csvs.py for CSV I/O such as automatically detecting the dialect based on the header line