csv.Sniffer

class csv.Sniffer The Sniffer class is used to deduce the format of a CSV file. The Sniffer class provides two methods: sniff(sample, delimiters=None) Analyze the given sample and return a Dialect subclass reflecting the parameters found. If the optional delimiters parameter is given, it is interpreted as a string containing possible valid delimiter characters. has_header(sample) Analyze the sample text (presumed to be in CSV format) and return True if the first row appears to be a

csv.list_dialects()

csv.list_dialects() Return the names of all registered dialects.

csv.Sniffer.has_header()

has_header(sample) Analyze the sample text (presumed to be in CSV format) and return True if the first row appears to be a series of column headers.

csv.register_dialect()

csv.register_dialect(name[, dialect[, **fmtparams]]) Associate dialect with name. name must be a string. The dialect can be specified either by passing a sub-class of Dialect, or by fmtparams keyword arguments, or both, with keyword arguments overriding parameters of the dialect. For full details about the dialect and formatting parameters, see section Dialects and Formatting Parameters.

csv.reader()

csv.reader(csvfile, dialect='excel', **fmtparams) Return a reader object which will iterate over lines in the given csvfile. csvfile can be any object which supports the iterator protocol and returns a string each time its __next__() method is called — file objects and list objects are both suitable. If csvfile is a file object, it should be opened with newline=''. [1] An optional dialect parameter can be given which is used to define a set of parameters specific to a particular CSV dialect.

csv.excel

class csv.excel The excel class defines the usual properties of an Excel-generated CSV file. It is registered with the dialect name 'excel'.

csv.get_dialect()

csv.get_dialect(name) Return the dialect associated with name. An Error is raised if name is not a registered dialect name. This function returns an immutable Dialect.

csv.field_size_limit()

csv.field_size_limit([new_limit]) Returns the current maximum field size allowed by the parser. If new_limit is given, this becomes the new limit.

csv.excel_tab

class csv.excel_tab The excel_tab class defines the usual properties of an Excel-generated TAB-delimited file. It is registered with the dialect name 'excel-tab'.

csv.Dialect.skipinitialspace

Dialect.skipinitialspace When True, whitespace immediately following the delimiter is ignored. The default is False.