z_csv_parser (zotonic_core v1.0.0-rc.17)

Parse CSV file into a nested list of lines and fields.

Summary

Functions

Check if the first row is made up of column headers. The file must have at least a name and a category column.

Parse a line into its columns, using a character a separator.

Parse CSV data with the comma separator.

Parse CSV data with a certain separator.

Scan the file (or device) and return lines with fields.

Scan the file (or device) and return lines with fields.

Types

line/0

-type line() :: [binary()].

lines/0

-type lines() :: [line()].

sep/0

-type sep() :: 44 | 59 | 9.

Functions

cleanup_field(L)

inspect_data(B0)

-spec inspect_data(binary()) -> {ok, line(), sep()} | {error, invalid_csv_file}.

Check if the first row is made up of column headers. The file must have at least a name and a category column.

inspect_file(Filename)

-spec inspect_file(file:filename_all()) -> {ok, line(), sep()} | {error, invalid_csv_file | term()}.

parse_line(Line, Sep)

Parse a line into its columns, using a character a separator.

scan_data(Data)

-spec scan_data(binary()) -> lines().

Parse CSV data with the comma separator.

scan_data(Data, Sep)

-spec scan_data(binary(), sep()) -> lines().

Parse CSV data with a certain separator.

scan_lines(DeviceOrFilename)

-spec scan_lines(file:filename_all() | pid()) -> lines().

Scan the file (or device) and return lines with fields.

scan_lines(Filename, FieldSep)

-spec scan_lines(file:filename_all() | pid(), sep()) -> lines().

Scan the file (or device) and return lines with fields.