cmd

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "0.26.0"

VERSION of csvtk

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "csvtk",
	Short: "A cross-platform, efficient and practical CSV/TSV toolkit",
	Long: fmt.Sprintf(`csvtk -- a cross-platform, efficient and practical CSV/TSV toolkit

Version: %s

Author: Wei Shen <shenwei356@gmail.com>

Documents  : http://shenwei356.github.io/csvtk
Source code: https://github.com/shenwei356/csvtk

Attention:

  1. The CSV parser requires all the lines have same number of fields/columns.
     Even lines with spaces will cause error. 
     Use '-I/--ignore-illegal-row' to skip these lines if neccessary.
  2. By default, csvtk thinks your files have header row, if not, switch flag "-H" on.
  3. Column names better be unique.
  4. By default, lines starting with "#" will be ignored, if the header row
     starts with "#", please assign flag "-C" another rare symbol, e.g. '$'.
  5. By default, csvtk handles CSV files, use flag "-t" for tab-delimited files.
  6. If double quotes exist in fields, use flag "-l".
  7. Do not mix use field (column) numbers and names.

Environment variables for frequently used global flags:

  - "CSVTK_T" for flag "-t/--tabs"
  - "CSVTK_H" for flag "-H/--no-header-row"

You can also create a soft link named "tsvtk" for "csvtk", 
which sets "-t/--tabs" by default.

`, VERSION),
}

RootCmd represents the base command when called without any subcommands

Functions

func ExcelColumnIndex added in v0.23.0

func ExcelColumnIndex(col int) string

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func NewCSVWriterChanByConfig

func NewCSVWriterChanByConfig(config Config) (chan []string, error)

NewCSVWriterChanByConfig returns a chanel which you can send record to write

func ParseByteSize added in v0.26.0

func ParseByteSize(val string) (int64, error)

ParseByteSize parses byte size from string

Types

type CSVReader

type CSVReader struct {
	Reader *csv.Reader

	Ch       chan CSVRecordsChunk
	MetaLine []byte // meta line of separator declaration used by MS Excel

	IgnoreEmptyRow   bool
	IgnoreIllegalRow bool

	NumEmptyRows   []int
	NumIllegalRows []int
	// contains filtered or unexported fields
}

CSVReader is

func NewCSVReader

func NewCSVReader(file string, bufferSize int, chunkSize int) (*CSVReader, error)

NewCSVReader is

func (*CSVReader) Run

func (csvReader *CSVReader) Run()

Run begins to read

type CSVRecordsChunk

type CSVRecordsChunk struct {
	ID   uint64
	Data [][]string
	Err  error
}

CSVRecordsChunk is chunk of CSV records

type Config

type Config struct {
	ChunkSize int
	NumCPUs   int

	Delimiter    rune
	OutDelimiter rune
	// QuoteChar   rune
	CommentChar rune
	LazyQuotes  bool

	Tabs        bool
	OutTabs     bool
	NoHeaderRow bool

	OutFile string

	IgnoreEmptyRow   bool
	IgnoreIllegalRow bool
}

Config is the struct containing all global flags

Jump to

Keyboard shortcuts

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