Documentation ¶
Index ¶
Constants ¶
const ( FormatUnknown = iota FormatCSV FormatTSV FormatJSON FormatJSONLines )
Variables ¶
This section is empty.
Functions ¶
func LoadTable ¶
LoadTable loads a table from the given reader, with the given format. If format is FormatUnknown, it attempts to auto-detect the format by peeking at the first few bytes of the input. It returns the detected format (or just the parameter format if it's not unknown), the loaded data and an error.
Types ¶
type Format ¶
type Format int
Format is the type of data we're expected to load into a table. The supported formats are: CSV (comma-separated values), TSV (tab-separated values), JSON (a JSON array of objects) and "line per JSON" which has a JSON object on each line. FormatUnknown means that LoadTable will attempt to auto-detect the format based on the first bytes of the input.
type Table ¶
type Table = []Row
Table is the data format loaded by LoadTable. Each row in the input is represented by a map from column name to column values. For example, for CSV data:
id,name 1,john 2,mary
The loaded table will be a slice of two maps:
[0]: {"id": "1", "name": "john"} [1]: {"id": "2", "name": "mary"}
For JSON data, the translation is more direct as LoadTable expects JSON representing an array of objects which maps directly to this type.