Changeset 1215


Ignore:
Timestamp:
Jul 8, 2011, 10:54:53 AM (8 years ago)
Author:
lindanl
Message:

CSV parsing: quote using parity method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/CSV/csv.py

    r372 r1215  
    4242        return escape
    4343       
    44 def parse_quote(quote,EOF_mask):       
     44def parse_quote_seq(quote,EOF_mask):   
    4545        cursor = 1
    4646        quote_start = 0
     
    5656        return  quote_mask
    5757       
    58        
     58def parse_quote_parity(quote,EOF_mask):
     59        p2 = quote ^ (quote << 1)
     60        p4 = p2 ^ (p2 << 2)
     61        p8 = p4 ^ (p4 << 4)
     62        p16 = p8 ^ (p8 << 8)
     63        p32 = p16 ^ (p16 << 16)
     64        p64 = p32 ^ (p32 << 32)
     65        quote_mask = p64 ^ (p64 << 64)
     66        return  quote_mask     
    5967       
    6068def csv_parse(u8data):
    61         # Transpose to parallel bit streams and prepare an EOF mask.
    6269        (bit, EOF_mask) = bitutil.transpose_streams(u8data)
    6370        lex = csvclass.classify_bytes(bit)
    6471        escape = parse_escape(lex, EOF_mask)   
    6572        quote = lex.DQuote &~ escape
    66         quote_mask = parse_quote(quote, EOF_mask)
     73        quote_mask = parse_quote_parity(quote, EOF_mask)
    6774        eol = (lex.CR&~quote_mask) | (lex.LF&~lex.CR&~quote_mask)
    6875        delim = lex.Comma&~quote_mask
     
    8895        if len(sys.argv) > 1:
    8996                u8data = bitutil.readfile(sys.argv[1])
    90 
    9197                demo_csv(u8data)
    9298        else:
Note: See TracChangeset for help on using the changeset viewer.