SparkseePython3 6.1.0
sparksee.CSVWriter Class Reference

CSVWriter interface. More...

Inheritance diagram for sparksee.CSVWriter:
Inheritance graph
Collaboration diagram for sparksee.CSVWriter:
Collaboration graph

Public Member Functions

 __init__ (self)
 Creates a new instance.
 set_separator (self, sep)
 Sets the character used to separate fields in the file.
 set_auto_quotes (self, autoquotes)
 Sets on/off the automatic quote mode.
 open (self, f)
 Opens the output file path.
 write (self, row)
 Writes the next row.
 set_forced_quotes (self, forcequotes)
 Disables the automatic quote mode and forces to be quoted those positions set to TRUE in the given vector.
 close (self)
 Closes the writer.
 set_locale (self, locale_str)
 Sets the locale that will be used to write the file.
 set_quotes (self, quotes)
 Sets the character used to quote fields.

Detailed Description

CSVWriter interface.

A very simple CSV writer implementing RowWriter.

It works as any other RowWriter, but open must be called once before the first write operation.

It uses the format RFC 4180: http://tools.ietf.org/html/rfc4180

You can use your own separators and quote characters. By default the separator is the comma (,) and the quote character is the double quotes (") and autoquote is enabled.

See the CSVReader locale documentation or the SPARKSEE User Manual.

Check out the 'Data export' section in the SPARKSEE User Manual for more details on this.

Author
Sparsity Technologies http://www.sparsity-technologies.com

Member Function Documentation

◆ close()

sparksee.CSVWriter.close ( self)

Closes the writer.

ErrorFor any issue

Exceptions
RuntimeErrornull
IOErrorIf the close fails.

Reimplemented from sparksee.RowWriter.

◆ open()

sparksee.CSVWriter.open ( self,
f )

Opens the output file path.

Parameters
f[in] Output file path.
Exceptions
IOErrorIf bad things happen opening the file.

◆ set_auto_quotes()

sparksee.CSVWriter.set_auto_quotes ( self,
autoquotes )

Sets on/off the automatic quote mode.

If there are forced quotes, setting autoquotes on will clear them. If the autoquotes is set to off and no forced quotes are provided, there will not be any quote.

Parameters
autoquotes[in] If TRUE it enables the automatic quote mode, if FALSE it disables it.

◆ set_forced_quotes()

sparksee.CSVWriter.set_forced_quotes ( self,
forcequotes )

Disables the automatic quote mode and forces to be quoted those positions set to TRUE in the given vector.

Parameters
forcequotes[in] A booleanList with the position for each column that must be quoted set to true.

◆ set_locale()

sparksee.CSVWriter.set_locale ( self,
locale_str )

Sets the locale that will be used to write the file.

Parameters
locale_str[in] The locale string for the file encoding.

◆ set_quotes()

sparksee.CSVWriter.set_quotes ( self,
quotes )

Sets the character used to quote fields.

Parameters
quotes[in] Quote character.
Exceptions
RuntimeErrorFor any issue

◆ set_separator()

sparksee.CSVWriter.set_separator ( self,
sep )

Sets the character used to separate fields in the file.

Parameters
sep[in] Separator character.
Exceptions
RuntimeErrorFor any issue

◆ write()

sparksee.CSVWriter.write ( self,
row )

Writes the next row.

ErrorFor any issue

Parameters
row[in] Row of data.
Exceptions
RuntimeErrornull
IOErrorIf bad things happen during the write.

Reimplemented from sparksee.RowWriter.