load-txt
lq.load-txt(data, delimiter=",", comments="#", skip-rows=0, usecols=auto, header=false, converters=float)
Parses a CSV (comma-separated values) string. This function enhances the
functionality of the built-in Typst function csv
with features like transforming
values to numerical (or other) types, ignoring comments and selecting only part of
the data.
Unlike the built-in csv
function, this function returns the data as a list of
columns and not as a list of rows.
data : str
Raw data loaded from a text file via read()
.
delimiter : str
default: ","
The delimiter that separates columns in the file.
comments : str
default: "#"
The characters that indicate the start of a single-line comment.
skip-rows : int
default: 0
The number of leading rows to be skipped, including comments.
usecols : auto
| array
default: auto
Which columns to extract from the file. Expects an array of indices to columns to
extract. If auto
, all columns are extracted.
header : bool
default: false
If true, the first line is interpreted as a header naming the individual columns. The result is then returned as a dictionary with the headers.
converters : function
| type
| dictionary
default: float
Optional converter functions or types to use to convert the data entries. This
can either be a single function or type that is applied to all columns likewise
or a dictionary with column indices as keys and functions or types as values.
Through the (optional) key rest
, a default converter can be specified to be used
for all columns that have no explicit converter assigned.