Project

General

Profile

« Previous | Next » 

Revision 5435

csvs.py: sniff(): Also autodetect the line ending

View differences:

lib/csvs.py
17 17

  
18 18
def sniff(line):
19 19
    '''Automatically detects the dialect'''
20
    line, ending = strings.extract_line_ending(line)
20 21
    dialect = csv.Sniffer().sniff(line, delims)
22
    
21 23
    # TSVs usually don't quote fields (nor doublequote embedded quotes)
22 24
    if is_tsv(dialect): dialect.quoting = csv.QUOTE_NONE
25
    
23 26
    else: dialect.doublequote = True # Sniffer doesn't turn this on by default
27
    dialect.lineterminator = ending
28
    
24 29
    return dialect
25 30

  
26 31
def stream_info(stream, parse_header=False):

Also available in: Unified diff