iolib

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CsvRecordIterator added in v0.3.0

func CsvRecordIterator(csvFilePath string) (iter.Seq2[[]string, error], error)

CsvRecordIterator returns a Seq2 iterator which includes the csvRecord and any errorlib encountered during the read operation.

func FileLinesIterator added in v0.3.0

func FileLinesIterator(csvFilePath string) (iter.Seq[string], error)

FileLinesIterator returns a Seq containing a single file line.

func MergeCsvFiles added in v0.3.0

func MergeCsvFiles(outputCsvPath string, hasHeader bool, inputCsvFiles ...string) error

MergeCsvFiles merges the provided inputFiles into a single file located at outputCsvPath. The first file in inputFiles establishes the merge file's structure and header row if hasHeader is true

func ReadFileContent

func ReadFileContent[T FileContent](filePath string) (T, error)

ReadFileContent returns the contents of a file as FileContent.

Types

type CsvWriter added in v0.2.0

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

CsvWriter writes CSV records to an output file. Use NewCsvWriter to create new instances and Close to close the underlying file.

func NewCsvWriter added in v0.2.0

func NewCsvWriter(csvFilePath string) (CsvWriter, error)

NewCsvWriter creates a new CsvWriter instance.

func (*CsvWriter) Close added in v0.2.0

func (w *CsvWriter) Close() error

Close closes the underlying CsvWriter file.

func (*CsvWriter) Error added in v0.2.0

func (w *CsvWriter) Error() error

Error returns the current errorlib

func (*CsvWriter) Flush added in v0.2.0

func (w *CsvWriter) Flush()

Flush writes unbuffered data to disk.

func (*CsvWriter) Write added in v0.2.0

func (w *CsvWriter) Write(csvRecord []string) error

Write writes a csvRecord to the underlying output file.

type FileContent

type FileContent interface {
	~string | ~[]byte
}

FileContent is the type set used in ReadFileContents

Jump to

Keyboard shortcuts

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