filehandler

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupDecompressedFiles added in v1.0.1

func CleanupDecompressedFiles(files []DecompressedFileInfo)

CleanupDecompressedFiles removes temporary decompressed files

func DecompressFile added in v1.0.1

func DecompressFile(filePath string) (string, error)

DecompressFile decompresses a file to a temporary file and returns the temp file path The caller is responsible for cleaning up the temp file

func DetectFormatsFromFiles added in v1.0.1

func DetectFormatsFromFiles(files []string) (map[string]Format, error)

DetectFormatsFromFiles returns a map of file path to format for each file

func GetUncompressedPath added in v1.0.1

func GetUncompressedPath(filePath string) string

GetUncompressedPath returns the path without the compression extension e.g., "data.csv.gz" -> "data.csv"

func GroupFilesByFormat added in v1.0.1

func GroupFilesByFormat(files []string) (map[Format][]string, error)

GroupFilesByFormat groups files by their format

func IsCompressed added in v1.0.1

func IsCompressed(filePath string) bool

IsCompressed checks if a file path has a compression extension

func IsFormatSupported

func IsFormatSupported(format string) bool

IsFormatSupported checks if a format is supported

func IsMQURL added in v1.0.0

func IsMQURL(urlStr string) bool

IsMQURL checks if the given URL is a message queue URL

Types

type Compression added in v1.0.1

type Compression string

Compression represents a supported compression format

const (
	CompressionNone  Compression = ""
	CompressionGzip  Compression = "gzip"
	CompressionBzip2 Compression = "bzip2"
	CompressionXZ    Compression = "xz"
	CompressionZstd  Compression = "zstd"
)

func DetectCompression added in v1.0.1

func DetectCompression(filePath string) Compression

DetectCompression detects if a file is compressed and returns the compression type

type DecompressedFileInfo added in v1.0.1

type DecompressedFileInfo struct {
	OriginalPath   string
	DecompressPath string
	WasCompressed  bool
	Format         Format
}

DecompressedFileInfo holds information about a decompressed file

func DecompressFiles added in v1.0.1

func DecompressFiles(files []string) ([]DecompressedFileInfo, error)

DecompressFiles decompresses all compressed files in the list Returns a list of DecompressedFileInfo with paths to the decompressed files

type FileHandler

type FileHandler interface {
	Import() error
	Lines() int
	Close() error
}

type Format

type Format string

Format represents a supported file format

const (
	FormatCSV      Format = "csv"
	FormatJSON     Format = "json"
	FormatJSONL    Format = "jsonl"
	FormatXML      Format = "xml"
	FormatExcel    Format = "excel"
	FormatParquet  Format = "parquet"
	FormatYAML     Format = "yaml"
	FormatAVRO     Format = "avro"
	FormatORC      Format = "orc"
	FormatPostgres Format = "postgres"
	FormatMySQL    Format = "mysql"
	FormatDuckDB   Format = "duckdb"
	FormatMongoDB  Format = "mongodb"
	FormatDynamoDB Format = "dynamodb"
	FormatSQLite   Format = "sqlite"
	FormatMQ       Format = "mq"    // Message Queue (SQS, Kafka, RabbitMQ, etc.)
	FormatMixed    Format = "mixed" // Mixed file formats (for JOINs across different formats)
)

func DetectFormat

func DetectFormat(filePath string) (Format, error)

DetectFormat detects the file format from file extension or URL scheme

func DetectFormatFromFiles

func DetectFormatFromFiles(files []string) (Format, error)

DetectFormatFromFiles detects the format from a list of files If all files have the same format, returns that format If files have mixed formats, returns FormatMixed

func GetInnerFormat added in v1.0.1

func GetInnerFormat(filePath string) (Format, error)

GetInnerFormat detects the format of a compressed file e.g., "data.csv.gz" -> FormatCSV

func SupportedFormats

func SupportedFormats() []Format

SupportedFormats returns a list of supported file formats

type HandlerFactory

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

HandlerFactory creates file handlers based on format

func NewHandlerFactory

func NewHandlerFactory(storage storage.Storage, bar *progressbar.ProgressBar, limitLines int, collection string, delimiter rune) *HandlerFactory

NewHandlerFactory creates a new handler factory

Directories

Path Synopsis
Package composite provides a file handler that can process multiple files of different formats
Package composite provides a file handler that can process multiple files of different formats
Package mq provides a FileHandler implementation for message queue sources.
Package mq provides a FileHandler implementation for message queue sources.

Jump to

Keyboard shortcuts

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