Skip to content

CSV

Inherits: LibTSMModule

Functions

DecodeEnd

lua
function Format.CSV.DecodeEnd(context)
  -> boolean

Ends a CSV decoding context and returns whether or not the data was fully decoded successfully.

Parameters:

NameTypeDescription
contexttableThe CSV decoding context

Returns:

TypeDescription
boolean

DecodeIterator

lua
function Format.CSV.DecodeIterator(context)
  -> fun():...any, table

Iterates over the CSV encoded data.

Parameters:

NameTypeDescription
contexttableThe CSV decoding context

Returns:

TypeDescription
fun():...anyIterator with fields matching the decoded values
table

DecodeStart

lua
function Format.CSV.DecodeStart(str, fields)
  -> table?

Creates a CSV decoding context for the specified fields.

Parameters:

NameTypeDescription
strstringThe CSV encoded data
fieldsstring[]The fields which are being decoded

Returns:

NameTypeDescription
contexttable?

Encode

lua
function Format.CSV.Encode(keys, data)
  -> string

Encodes the specified data to a CSV string.

Parameters:

NameTypeDescription
keysstring[]The list of keys to encode
datatableThe data to encode

Returns:

TypeDescription
string

EncodeAddRowData

lua
function Format.CSV.EncodeAddRowData(context, data)

Adds a row to the CSV encoding context.

Parameters:

NameTypeDescription
contexttableThe CSV encoding context
datatableThe data for the row

EncodeAddRowDataRaw

lua
function Format.CSV.EncodeAddRowDataRaw(context, ...)

Adds a raw row to the CSV encoding context.

Parameters:

NameTypeDescription
contexttableThe CSV encoding context
...stringThe raw data for the row

EncodeEnd

lua
function Format.CSV.EncodeEnd(context)
  -> string

Ends a CSV encoding context and returns the resulting CSV string.

Parameters:

NameTypeDescription
contexttableThe CSV encoding context

Returns:

TypeDescription
string

EncodeStart

lua
function Format.CSV.EncodeStart(keys)
  -> table

Creates a CSV encoding context for the specified keys.

Parameters:

NameTypeDescription
keysstring[]The keys which are being encoded

Returns:

TypeDescription
table