Gnm.StfParseOptions_t

Fields

Name

Type

Access

Description

col_autofit_array

bool

r/w

col_import_array

bool

r/w

col_import_array_len

int

r/w

cols_exceeded

bool

r/w

compiled_terminator

object

r/w

formats

[object]

r/w

formats_curr

[object]

r/w

formats_decimal

[object]

r/w

formats_thousand

[object]

r/w

indicator_2x_is_single

bool

r/w

locale

str

r/w

parsetype

Gnm.StfParseType_t

r/w

ref_count

int

r/w

rows_exceeded

bool

r/w

sep

object

r/w

splitpositions

[object]

r/w

stringindicator

str

r/w

terminator

[object]

r/w

trim_seps

bool

r/w

trim_spaces

Gnm.StfTrimType_t

r/w

Methods

class

guess (data)

class

guess_csv (data)

add_line_terminator (terminator)

clear_line_terminator ()

csv_set_duplicates (duplicates)

csv_set_indicator_2x_is_single (indic_2x)

csv_set_separators (character, seps)

csv_set_stringindicator (stringindicator)

csv_set_trim_seps (trim_seps)

fixed_autodiscover (data, data_end)

fixed_splitpositions_add (position)

fixed_splitpositions_clear ()

fixed_splitpositions_count ()

fixed_splitpositions_nth (n)

fixed_splitpositions_remove (position)

free ()

guess_formats (data)

set_trim_spaces (trim_spaces)

set_type (parsetype)

Details

class Gnm.StfParseOptions_t
classmethod guess(data)
Parameters:

data (str) – the input data.

Returns:

the guessed options.

Return type:

Gnm.StfParseOptions_t

classmethod guess_csv(data)
Parameters:

data (str) – the CSV input data.

Returns:

the guessed options.

Return type:

Gnm.StfParseOptions_t

add_line_terminator(terminator)
Parameters:

terminator (str) –

This will add to the line terminators, in both the Fixed width and CSV delimited importers this indicates the end of a Gnm.row.

clear_line_terminator()

This will clear the line terminator, in both the Fixed width and CSV delimited importers this indicates the end of a Gnm.row.

csv_set_duplicates(duplicates)
Parameters:

duplicates (bool) – a boolean GOffice.value indicating whether we want to see two separators right behind each other as one

csv_set_indicator_2x_is_single(indic_2x)
Parameters:

indic_2x (bool) – a boolean GOffice.value indicating whether we want to see two adjacent string indicators as a single string indicator that is part of the cell, rather than a terminator.

csv_set_separators(character, seps)
Parameters:
  • character (str) –

  • seps ([str]) – the separators to be used

A copy is made of the parameters.

csv_set_stringindicator(stringindicator)
Parameters:

stringindicator (str) –

csv_set_trim_seps(trim_seps)
Parameters:

trim_seps (bool) – a boolean GOffice.value indicating whether we want to ignore separators at the beginning of lines

fixed_autodiscover(data, data_end)
Parameters:
  • data (str) – The actual data.

  • data_end (str) – data end.

Automatically try to discover columns in the text to be parsed. We ignore empty lines (only containing parseoptions->terminator)

FIXME: This is so extremely ugly that I am too tired to rewrite it right now. Think hard of a better more flexible solution…

fixed_splitpositions_add(position)
Parameters:

position (int) –

position will be added to the splitpositions.

fixed_splitpositions_clear()

This will clear the splitpositions (== points on which a line is split)

fixed_splitpositions_count()
Return type:

int

fixed_splitpositions_nth(n)
Parameters:

n (int) –

Return type:

int

fixed_splitpositions_remove(position)
Parameters:

position (int) –

free()

will free self, note that this will not free the splitpositions member (GLib.Array) of the struct, the caller is responsible for that.

guess_formats(data)
Parameters:

data (str) – the CSV input data.

This function attempts to recognize data formats on a column-by-column basis under the assumption that the data in a text file will generally use the same data formats.

This is useful because not all values give sufficient information by themselves to tell what format the data is in. For example, “1/2/2000” is likely to be a date in year 2000, but it is not clear if it is in January or February. If another GOffice.value in the same column is “31/1/1999” then it is likely that the former date was in February.

Likewise, a GOffice.value of “123,456” could mean either 1.23456e5 or 1.23456e2. A later GOffice.value of “111,200.22” would clear up the confusion.

set_trim_spaces(trim_spaces)
Parameters:

trim_spaces (Gnm.StfTrimType_t) –

If enabled will trim spaces in every parsed field on left and/or right sides.

set_type(parsetype)
Parameters:

parsetype (Gnm.StfParseType_t) –