csvutils

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Zlib Imports: 8 Imported by: 1

README

csvutils

Go Reference

CSV utility library for Go.

Installation

  1. Run go get git.mirkodi.eu/mirk0dex/csvutils in your terminal emulator of choice, inside the directory your Go source code is;

  2. add the following to your imports:

    csvutils "git.mirkodi.eu/mirk0dex/csvutils"

    .

    So, for instance, if the top of your source file looked like this:

        import (
            "fmt"
        )
    

    it would now look like this:

    import (
        "fmt"
    
        csvutils "git.mirkodi.eu/mirk0dex/csvutils"
    )
    

    .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSVToMap

func CSVToMap(filename string, keyPosition, valuePosition int) (map[string]string, error)

returns given CSV file's contents as map[string]string

func CSVToMapMulti

func CSVToMapMulti(filename string, keyPosition int, valuePositions ...int) (map[string][]string, error)

returns given CSV file's contents as map[string][]string

func CSVToMapMultiReader added in v1.3.0

func CSVToMapMultiReader(f io.Reader, keyPosition int, valuePositions ...int) (map[string][]string, error)

returns given CSV file's contents as map[string][]string (but with io.Reader arg)

func CSVToMapReader added in v1.3.0

func CSVToMapReader(f io.Reader, keyPosition, valuePosition int) (map[string]string, error)

func GetCSVValue

func GetCSVValue(filename, pattern string, positionOfValueToReturn, positionOfValueToLookFor int, caseSensitive, contains bool) (string, error)

gets value in position positionOfValueToReturn in the line where pattern is found at position positionOfValueToLookFor

func GetCSVValueReader added in v1.3.0

func GetCSVValueReader(f io.Reader, pattern string, positionOfValueToReturn, positionOfValueToLookFor int, caseSensitive, contains bool) (string, error)

func GetCSVValueWhereStringIsFound

func GetCSVValueWhereStringIsFound(filename string, n int, stringToLookFor string, caseSensitive bool) (string, error)

returns value at column n at line where string is found; returns strNil if nothing is found

NOTE: columns start from 0

func GetCSVValueWhereStringIsFoundReader added in v1.3.0

func GetCSVValueWhereStringIsFoundReader(f io.Reader, n int, stringToLookFor string, caseSensitive bool) (string, error)

func GetValuesInColumnNFromCSV

func GetValuesInColumnNFromCSV(filename string, n int) ([]string, error)

get all values in column n in CSV file

func GetValuesInColumnNFromCSVReader added in v1.3.0

func GetValuesInColumnNFromCSVReader(f io.Reader, n int) ([]string, error)

get all values in column n in CSV file (io.Reader)

func OnCSV

func OnCSV(filename string, minValues int, function func(i int, record []string)) error

run given function on each line in CSV

func OnCSVCSVReader added in v1.3.0

func OnCSVCSVReader(r *csv.Reader, minValues int, function func(i int, record []string)) error

OnCSV(), but *csv.Reader must be passed instead of a filename or a io.Reader

func OnCSVReader added in v1.1.1

func OnCSVReader(f io.Reader, minValues int, function func(i int, record []string)) error

OnCSV(), but io.Reader must be passed instead of a filename

func OnEachLineCSV

func OnEachLineCSV(filename string, minValues int, function func(i int, record []string)) error

alias for OnCSV()

func OnEachLineCSVReader added in v1.1.1

func OnEachLineCSVReader(f io.Reader, minValues int, function func(i int, record []string)) error

alias for OnCSVReader()

Types

This section is empty.

Jump to

Keyboard shortcuts

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