csvparser

package
v0.0.0-...-266bd3a Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package csvparser helps parsing a CSV file with a callback.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(ctx context.Context, path string, callback Callback, options Options) error

Parse parses a CSV file and calls the given callback.

Types

type Callback

type Callback struct {
	// Every is the number of records to read before calling the callback.
	Every int

	// Do is the function called after Every number of records has been
	// reached. The records length is equal to Every or less for the last
	// records.
	Do func(ctx context.Context, records [][]string) error
}

Callback is a function which is called while parsing a CSV file.

type Options

type Options struct {
	// Comma is the separator to use while parsing.
	Comma rune
	// SkipFirstLine skips the first line if true.
	SkipFirstLine bool
}

Options gathers the parsing options.

Jump to

Keyboard shortcuts

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