Documentation
¶
Overview ¶
Package sheet is the CLI's canonical spreadsheet model plus parsers and emitters for CSV, TSV, JSON, JSONL and XLSX. It mirrors the Demografix browser tool's semantics so enriched output matches the web download.
Index ¶
- func CellToString(c Cell) string
- func DetectAndDecode(b []byte) (string, Encoding, BOM, error)
- func FormatFloatShort(f float64) string
- func WriteFile(path string, s *Spreadsheet) error
- func WriteTo(w io.Writer, s *Spreadsheet) error
- type BOM
- type Cell
- type DateCell
- type DateTimeCell
- type Encoding
- type Format
- type JSONTop
- type Meta
- type RawNumber
- type Spreadsheet
- type UnsupportedFormatError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CellToString ¶
CellToString stringifies a cell exactly like the Elixir cell_to_string/1.
func DetectAndDecode ¶
DetectAndDecode decodes input bytes to a UTF-8 string, detecting a BOM and falling back to Windows-1252 for non-UTF-8 input without a BOM.
func FormatFloatShort ¶
FormatFloatShort renders a float exactly like Erlang :short / Jason: the shortest round-trip digits, formatted positionally or in scientific notation (whichever is shorter; ties prefer positional), always keeping a decimal point. The mantissa carries a ".0" when whole, and the exponent is printed without a leading zero or '+' (e.g. "1.0e3", "1.23e-4", "0.0001").
func WriteFile ¶
func WriteFile(path string, s *Spreadsheet) error
WriteFile writes the spreadsheet to a file path.
Types ¶
type Cell ¶
type Cell = any
Cell is one canonical cell value: nil | string | int64 | float64 | bool | DateCell | DateTimeCell | []Cell | map[string]Cell.
type DateTimeCell ¶
DateCell is a date-only value; DateTimeCell carries a time component.
type Encoding ¶
type Encoding int
Encoding records the detected input encoding (output is always UTF-8).
type Meta ¶
Meta carries format-specific parsing details needed to re-emit faithfully.
func DefaultMeta ¶
DefaultMeta returns sensible Meta when converting to a format.
type RawNumber ¶
type RawNumber string
RawNumber preserves a numeric literal that cannot be represented as a Go int64/float64 without loss (e.g. a 20-digit id). It is emitted verbatim.
type Spreadsheet ¶
type Spreadsheet struct {
Format Format
Headers []string
Rows [][]Cell
Encoding Encoding
BOM BOM
Meta Meta
}
Spreadsheet is the materialized representation of a parsed file.
func Parse ¶
func Parse(path string) (*Spreadsheet, error)
Parse reads and parses a spreadsheet file, dispatching by extension.
type UnsupportedFormatError ¶
UnsupportedFormatError is returned for an unrecognized input or output file extension. The CLI maps it to a usage exit code.
func (*UnsupportedFormatError) Error ¶
func (e *UnsupportedFormatError) Error() string