def split(self, s):
        """Splits a string into a list of (start_column, substring) tuples."""

        normalized = "".join(map(lambda c: " " if c.isspace() else c, s))

        string = False
        quote = False
        v = []
        for col, char in enumerate(normalized.rstrip(), 1):
            if char == '\\':
                quote = True
            if char == '"' and not quote:
                if string:
                    v[-1] = (v[-1][0], v[-1][1] + '"')
                string = not string

            if char.isspace() and not string:
                v.append((col, ""))
            else:
                if len(v) == 0:
                    v.append((col, char))
                else:
                    col, part = v[-1]
                    v[-1] = (col, part + char)

            if char != '\\' and quote:
                quote = False

        return [t_p for t_p in v if t_p[1] != ""]
def split ( self , s ) : normalized = "" . join ( map ( lambda c : " " if c . isspace ( ) else c , s ) ) string = False quote = False v = [ ] for col , char in enumerate ( normalized . rstrip ( ) , 1 ) : if char == '\\' : quote = True if char == '"' and not quote : if string : v [ - 1 ] = ( v [ - 1 ] [ 0 ] , v [ - 1 ] [ 1 ] + '"' ) string = not string if char . isspace ( ) and not string : v . append ( ( col , "" ) ) else : if len ( v ) == 0 : v . append ( ( col , char ) ) else : col , part = v [ - 1 ] v [ - 1 ] = ( col , part + char ) if char != '\\' and quote : quote = False return [ t_p for t_p in v if t_p [ 1 ] != "" ]
Splits a string into a list of (start_column, substring) tuples.