csvlike.csv module

Module providing a custom CSV file parser with support for whitespace trimming, empty lines filtering and comment lines

exception csvlike.csv.CSVParserError(message, line, char, index)[source]

Bases: ValueError

Some error occured while attempting to parse the file

class csvlike.csv.DefaultDialect[source]

Bases: csvlike.csv.Dialect

Default csv-like dialect, using comma separators, double quote chars and hash as the comment char with newline and tab char trimming.

commentchar = '#'
delimiter = ','
ignoreemptylines = True
quotechar = '"'
trimleft = ' \t\n\r'
trimright = ' \t\n\r'
class csvlike.csv.Dialect[source]

Bases: object

Abstract base class for Dialect

commentchar = None
delimiter = None
quotechar = None
trimleft = None
trimright = None
exception csvlike.csv.InvalidDialectError[source]

Bases: ValueError

An invalid dialect was supplied

class csvlike.csv.Line(iterable=(), /)[source]

Bases: list

property lineno
class csvlike.csv.Reader(file: TextIO, dialect: csvlike.csv.Dialect, debug=None)[source]

Bases: object

CSV-like file reader with support for comment chars, ignoring empty lines and whitespace trimming on both sides of each field.

exception csvlike.csv.UnallowedQuoteError(message, line, char, index)[source]

Bases: csvlike.csv.CSVParserError

A quote is not allowed there

exception csvlike.csv.UnclosedQuoteError(message, line, char, index)[source]

Bases: csvlike.csv.CSVParserError

A quote wasn't properly closed

exception csvlike.csv.UnknownDialectError[source]

Bases: ValueError

An unknown dialect was requested

class csvlike.csv.WhitespaceDialect[source]

Bases: csvlike.csv.DefaultDialect

Same as default Dialect, but with spaces also trimmed.

delimiter = ' \t'
csvlike.csv.reader(file: TextIO, dialect: Union[None, str, csvlike.csv.Dialect] = None, **kwargs)csvlike.csv.Reader[source]