erl_csv (erl_csv v0.1.0+build.7.ref239a318) View Source
Link to this section Summary
Functions
Decode a stream of comma-separated lines into a stream of rows. The Decoder expects line by line input of valid csv lines with inlined escape sequences if you use it directly.
Encode a table stream into a stream of RFC 4180 compliant CSV lines for writing to a file or other IO.
Link to this section Types
Specs
csv_stream() :: #csv_stream{} | stream_end.
Specs
decode_opts() ::
#{quotes => <<_:8>>, separator => <<_:8>>, delimiter => binary(), regex => term()}.
Specs
encode_opts() :: #{headers => boolean() | list(), separator => <<_:8>>, delimiter => binary()}.
Link to this section Functions
Specs
decode(binary()) -> {ok, binary()} | {has_trailer, binary(), binary()} | {nomatch, binary()}.
Decode a stream of comma-separated lines into a stream of rows. The Decoder expects line by line input of valid csv lines with inlined escape sequences if you use it directly.
Options
* :separator – The separator token to use, defaults to ?,. Must be a codepoint (syntax: ? + (your separator)).
:headers – When set to true, will take the first row of the csv and use it as header values. When set to a list, will use the given list as header values. When set to false (default), will use no header values. When set to anything but false, the resulting rows in the matrix will be maps instead of lists.
Specs
decode(binary(), decode_opts()) -> {ok, binary()} | {has_trailer, binary(), binary()} | {nomatch, binary()}.
Specs
decode_new_s(file:name_all()) -> {ok, csv_stream()} | {error, term()}.
Specs
decode_new_s(file:name_all(), decode_opts()) -> {ok, csv_stream()} | {error, term()}.
Specs
decode_s(csv_stream()) -> {ok, iolist(), csv_stream()} | {error, term()}.
Specs
encode(iolist() | [map()]) -> iolist().
Encode a table stream into a stream of RFC 4180 compliant CSV lines for writing to a file or other IO.
Options
* :separator – The separator token to use, defaults to ?,. Must be a codepoint (syntax: ? + your separator token).
* :delimiter – The delimiter token to use, defaults to \"\\r\\n\".
:headers – When set to true, uses the keys of the first map as the first element in the stream. All subsequent elements are the values of the maps. When set to a list, will use the given list as the first element in the stream and order all subsequent elements using that list. When set to false (default), will use the raw inputs as elements. When set to anything but false, all elements in the input stream are assumed to be maps.
Specs
encode(iolist() | [map()], encode_opts()) -> iolist().