csvsource

package
v0.43.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCsvFSSource added in v0.40.0

func NewCsvFSSource(sys fs.FS, filePath string) *arraysource.Model

NewCsvFSSource reads a CSV file from an embedded filesystem (embed.FS / fs.FS), infers column types, and returns an array-backed data source ready for querying.

func NewCsvFSSourceWithDelimiter added in v0.40.0

func NewCsvFSSourceWithDelimiter(sys fs.FS, filePath string, delimiter rune) *arraysource.Model

NewCsvFSSourceWithDelimiter reads a CSV file from an embedded filesystem (embed.FS / fs.FS) with a custom field delimiter and returns an array-backed data source.

func NewCsvFileSource

func NewCsvFileSource(filePath string) *arraysource.Model

NewCsvFileSource reads a CSV file, infers column types, and returns an array-backed data source ready for querying with the array driver.

The first row of the file must be a header row defining column names. Remaining rows are parsed with type inference: each value is tried as int, then float, then bool, then time (RFC3339 and common date formats), falling back to string. Type widening applies across rows — a column with mixed int and float values becomes float.

The table name is derived from the filename (without the extension). For example, "data/users.csv" → table name "users". Override with the .Table() method on the returned model if needed.

database.Query().
    Model(neat.NewCsvFileSource("data/users.csv")).
    Where("active = ?", true).
    Get(&users)

Panics if the file cannot be opened, is empty, or has no header row — these are programmer errors (wrong path, malformed file), not runtime conditions.

func NewCsvFileSourceWithDelimiter

func NewCsvFileSourceWithDelimiter(filePath string, delimiter rune) *arraysource.Model

NewCsvFileSourceWithDelimiter is like NewCsvFileSource but allows specifying a custom field delimiter (e.g., '\t' for TSV files).

database.Query().
    Model(neat.NewCsvFileSourceWithDelimiter("data/events.tsv", '\t')).
    Get(&events)

func NewCsvSource

func NewCsvSource(csvString string, tableName string) *arraysource.Model

NewCsvSource parses a CSV string and returns an array-backed data source ready for querying with the array driver.

The first line must be a header row defining column names. Remaining lines are parsed with type inference: each value is tried as int, then float, then bool, then time (RFC3339 and common date formats), falling back to string. Type widening applies across rows — a column with mixed int and float values becomes float.

The table name must be provided explicitly since there is no filename to derive it from. Override with the .Table() method on the returned model if needed.

database.Query().
    Model(neat.NewCsvSource(csvString, "users")).
    Where("active = ?", true).
    Get(&users)

Panics if the CSV string is empty or has no header row — these are programmer errors, not runtime conditions.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL