Table Syntax Details
The Table syntax is both flexible and strict.
Flexible
A table need not have ANY rows of data
[planets]
name mass distance moons index mnemonic
string float64 float64 int int string
Some other data formats require at least one row of data to divine the data type of each column. That’s not necessary here, because all column types are specified explicitly. Parsing is more tolerant in some cases, such as a float written without a decimal point.
A table need not have ANY columns
[planets]
The table name without a table body may look lonely, but when instantiated in a program
it will create a new *gotables.Table
object (with the name planets
in this case) ready
for you to append columns and rows.
See example of how to instantiate a *gotables.Table
table syntax from a string
Strict
A table must have BOTH column names AND column types or NEITHER
You cannot have a column name without a column type, or a column type without a column name.
The number of column names, column types and data cells must match exactly.
It is an error to have an uneven number of column names, column types or row cells.
A table is terminated by a blank line or end of input: end of string, end of file.
- At least one blank line is needed between the end of one table and the beginning of the next.
- End of file is also considered end of table. No need to have an extra blank line at the end.
- End of string is also considered end of table. No need to have an extra blank line at the end.