csv

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCSVPrefix

func CheckCSVPrefix(file string, prefix string) (string, bool)

CheckCSVPrefix check file whether matched prefix. return false when not matched. return the remaining part(exclude ".csv" suffix) and true when matched.

func FileExists

func FileExists(path string) bool

Check if file exists

func GetAllCsvFiles

func GetAllCsvFiles(dirPath string) ([]string, error)

GetAllCsvFiles get all csv files from current dir not sub dirs

func NewCSVFile

func NewCSVFile(r io.Reader) (*csvFile, error)

NewCSVFile create a CSVFile from io.Reader

func NewCSVFileFromFile

func NewCSVFileFromFile(fileName string) (*csvFile, error)

NewCSVFileFromFile create a CSVFile from a physic file path

func ReadCSV

func ReadCSV(fileName string) ([][]string, error)

ReadCSV read a csv file to [][]string

func ReadCSV2Array

func ReadCSV2Array(fileName string) ([]map[string]string, error)

ReadCSV2Array read a csv file to []map[string]string

func ReadCSV2MapWithPrimaryKey

func ReadCSV2MapWithPrimaryKey(fileName string, primaryKeyColumn int) (map[string]map[string]string, error)

ReadCSV2MapWithPrimaryKey read a csv file to map[string]map[string]string

func SelfDir

func SelfDir() string

Get compiled executable file directory

func SelfPath

func SelfPath() string

Get compiled executable file absolute path

func SkipBom

func SkipBom(file *os.File) bool

SkipBom will remove bom from the file if it has bom

 will skip any error occur during the process, and reset to start position
return true means bom is skipped , or no bom is skipped

func StrToBool added in v0.1.7

func StrToBool(str string) bool

func StrToFloat32 added in v0.1.7

func StrToFloat32(str string) float32

func StrToFloat64 added in v0.1.7

func StrToFloat64(str string) float64

func StrToInt32 added in v0.1.7

func StrToInt32(str string) int32

func StrToInt32Slice added in v0.1.7

func StrToInt32Slice(str, sep string) []int32

func StrToInt64 added in v0.1.7

func StrToInt64(str string) int64

func StrToInt64Slice added in v0.1.7

func StrToInt64Slice(str, sep string) []int64

func StrToUint32 added in v0.1.7

func StrToUint32(str string) uint32

func StrToUint32Slice added in v0.1.7

func StrToUint32Slice(str, sep string) []uint32

func StrToUint64 added in v0.1.7

func StrToUint64(str string) uint64

func StrToUint64Slice added in v0.1.7

func StrToUint64Slice(str, sep string) []uint64

Types

type CSVFile

type CSVFile interface {
	// AsMapWithPrimaryKey convert content to map[string]map[string]string
	AsMapWithPrimaryKey(primaryKeyColumn int) (map[string]map[string]string, error)

	// AsArray convert content to []map[string]string
	AsArray() ([]map[string]string, error)
}

type SkipBomReader

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

func NewSkipBomReader

func NewSkipBomReader(r io.Reader) *SkipBomReader

NewSkipBomReader returns a reader which can remove bom from the given io.Reader if it has bom

func (*SkipBomReader) Read

func (r *SkipBomReader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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