model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package model provides domain model for filesql

Index

Constants

View Source
const (
	// ExtCSV is the CSV file extension
	ExtCSV = ".csv"
	// ExtTSV is the TSV file extension
	ExtTSV = ".tsv"
	// ExtLTSV is the LTSV file extension
	ExtLTSV = ".ltsv"
	// ExtGZ is the gzip compression extension
	ExtGZ = ".gz"
	// ExtBZ2 is the bzip2 compression extension
	ExtBZ2 = ".bz2"
	// ExtXZ is the xz compression extension
	ExtXZ = ".xz"
	// ExtZSTD is the zstd compression extension
	ExtZSTD = ".zst"
)

File extensions

Variables

View Source
var ErrDuplicateColumnName = errors.New("duplicate column name")

ErrDuplicateColumnName is returned when a file contains duplicate column names

Functions

func IsSupportedFile

func IsSupportedFile(fileName string) bool

IsSupportedFile checks if the file has a supported extension

func SupportedFileExtPatterns added in v0.1.0

func SupportedFileExtPatterns() []string

SupportedFileExtPatterns returns all supported file patterns for glob matching

func TableFromFilePath

func TableFromFilePath(filePath string) string

TableFromFilePath creates table name from file path

Types

type CompressionType added in v0.0.4

type CompressionType int

CompressionType represents the compression type

const (
	// CompressionNone represents no compression
	CompressionNone CompressionType = iota
	// CompressionGZ represents gzip compression
	CompressionGZ
	// CompressionBZ2 represents bzip2 compression
	CompressionBZ2
	// CompressionXZ represents xz compression
	CompressionXZ
	// CompressionZSTD represents zstd compression
	CompressionZSTD
)

func (CompressionType) Extension added in v0.0.4

func (c CompressionType) Extension() string

Extension returns the file extension for the compression type

func (CompressionType) String added in v0.0.4

func (c CompressionType) String() string

String returns the string representation of CompressionType

type DumpOptions added in v0.0.4

type DumpOptions struct {
	// Format specifies the output file format
	Format OutputFormat
	// Compression specifies the compression type
	Compression CompressionType
}

DumpOptions represents options for dumping database

func NewDumpOptions added in v0.0.4

func NewDumpOptions() DumpOptions

NewDumpOptions creates new DumpOptions with default values (CSV format, no compression)

func (DumpOptions) FileExtension added in v0.0.4

func (o DumpOptions) FileExtension() string

FileExtension returns the complete file extension including compression

func (DumpOptions) WithCompression added in v0.0.4

func (o DumpOptions) WithCompression(compression CompressionType) DumpOptions

WithCompression sets the compression type

func (DumpOptions) WithFormat added in v0.0.4

func (o DumpOptions) WithFormat(format OutputFormat) DumpOptions

WithFormat sets the output format

type File

type File struct {
	// contains filtered or unexported fields
}

File represents a file that can be converted to Table

func NewFile

func NewFile(path string) *File

NewFile creates a new File

func (*File) IsBZ2

func (f *File) IsBZ2() bool

IsBZ2 returns true if file is bzip2 compressed

func (*File) IsCSV

func (f *File) IsCSV() bool

IsCSV returns true if the file is CSV format

func (*File) IsCompressed

func (f *File) IsCompressed() bool

IsCompressed returns true if file is compressed

func (*File) IsGZ

func (f *File) IsGZ() bool

IsGZ returns true if file is gzip compressed

func (*File) IsLTSV

func (f *File) IsLTSV() bool

IsLTSV returns true if the file is LTSV format

func (*File) IsTSV

func (f *File) IsTSV() bool

IsTSV returns true if the file is TSV format

func (*File) IsXZ

func (f *File) IsXZ() bool

IsXZ returns true if file is xz compressed

func (*File) IsZSTD

func (f *File) IsZSTD() bool

IsZSTD returns true if file is zstd compressed

func (*File) Path

func (f *File) Path() string

Path returns file path

func (*File) ToTable

func (f *File) ToTable() (*Table, error)

ToTable converts file to Table structure

func (*File) Type

func (f *File) Type() FileType

Type returns file type

type FileType

type FileType int

FileType represents supported file types

const (
	// FileTypeCSV represents CSV file type
	FileTypeCSV FileType = iota
	// FileTypeTSV represents TSV file type
	FileTypeTSV
	// FileTypeLTSV represents LTSV file type
	FileTypeLTSV
	// FileTypeUnsupported represents unsupported file type
	FileTypeUnsupported
)
type Header []string

Header is file header.

func NewHeader

func NewHeader(h []string) Header

NewHeader create new Header.

func (Header) Equal

func (h Header) Equal(h2 Header) bool

Equal compare Header.

type OutputFormat added in v0.0.4

type OutputFormat int

OutputFormat represents the output file format

const (
	// OutputFormatCSV represents CSV output format
	OutputFormatCSV OutputFormat = iota
	// OutputFormatTSV represents TSV output format
	OutputFormatTSV
	// OutputFormatLTSV represents LTSV output format
	OutputFormatLTSV
)

func (OutputFormat) Extension added in v0.0.4

func (f OutputFormat) Extension() string

Extension returns the file extension for the format

func (OutputFormat) String added in v0.0.4

func (f OutputFormat) String() string

String returns the string representation of OutputFormat

type Record

type Record []string

Record is file records.

func NewRecord

func NewRecord(r []string) Record

NewRecord create new Record.

func (Record) Equal

func (r Record) Equal(r2 Record) bool

Equal compare Record.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table represents file contents as database table structure.

func NewTable

func NewTable(
	name string,
	header Header,
	records []Record,
) *Table

NewTable create new Table.

func (*Table) Equal

func (t *Table) Equal(t2 *Table) bool

Equal compare Table.

func (*Table) Header

func (t *Table) Header() Header

Header return table header.

func (*Table) Name

func (t *Table) Name() string

Name return table name.

func (*Table) Records

func (t *Table) Records() []Record

Records return table records.

Jump to

Keyboard shortcuts

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