gws.plugin.csv_helper

Common csv writer helper.

Source code: gws.plugin.csv_helper

Package Contents

class gws.plugin.csv_helper.Config(*args, **kwargs)

Bases: gws.Config

CSV helper.

format: FormatConfig

CSV format settings.

class gws.plugin.csv_helper.Format(*args, **kwargs)

Bases: gws.Data

Basic data object.

This object can be instantiated by passing one or or dict arguments and/or keyword args. All dicts keys and keywords become attributes of the object.

Accessing an undefined attribute returns None and no error is raised, unless the attribute name starts with an underscore.

delimiter: str
encoding: str
formulaHack: bool
quote: str
quoteAll: bool
rowDelimiter: str
class gws.plugin.csv_helper.FormatConfig(*args, **kwargs)

Bases: gws.Config

CSV format settings

delimiter: str = ','

Field delimiter.

encoding: str = 'utf8'

Text encoding.

formulaHack: bool = True

Prepend numeric strings with an equals sign.

quote: str = '"'

Quote character.

quoteAll: bool = False

Quote all fields.

rowDelimiter: str = 'LF'

Row delimiter.

class gws.plugin.csv_helper.Object

Bases: gws.Node

GWS object tree node.

format: Format
configure() None

Configure the CSV helper with format settings from config.

Sets up the format attribute with values from configuration or defaults.

writer(locale: gws.Locale, stream_to: BinaryIO = None) _Writer

Creates a new CSV Writer.

Parameters:
  • locale – Locale to use for formatting values.

  • stream_to – Optional binary stream to write to. If None, data is stored in memory.

Returns:

A new _Writer instance configured with this helper’s format settings.