Documentation ¶
Index ¶
Constants ¶
View Source
const VERSION = "0.30.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. By default, csvtk assumes input files have header row, if not, switch flag "-H" on. 2. By default, csvtk handles CSV files, use flag "-t" for tab-delimited files. 3. Column names should 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. Do not mix use field (column) numbers and names to specify columns to operate. 6. The CSV parser requires all the lines have same numbers of fields/columns. Even lines with spaces will cause error. Use '-I/--ignore-illegal-row' to skip these lines if neccessary. You can also use "csvtk fix" to fix files with different numbers of columns in rows. 7. If double-quotes exist in fields not enclosed with double-quotes, e.g., x,a "b" c,1 It would report error: bare " in non-quoted-field. Please switch on the flag "-l" or use "csvtk fix-quotes" to fix it. 8. If somes fields have only a double-quote eighter in the beginning or in the end, e.g., x,d "e","a" b c,1 It would report error: extraneous or missing " in quoted-field Please use "csvtk fix-quotes" to fix it, and use "csvtk del-quotes" to reset to the original format as needed. Environment variables for frequently used global flags: - "CSVTK_T" for flag "-t/--tabs" - "CSVTK_H" for flag "-H/--no-header-row" - "CSVTK_QUIET" for flag "--quiet" 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 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 ¶
NewCSVWriterChanByConfig returns a chanel which you can send record to write
func ParseByteSize ¶ added in v0.26.0
ParseByteSize parses byte size from string
Types ¶
type CSVReader ¶
type CSVReader struct { NoHeaderRow bool ShowRowNumber bool Reader *csv.Reader Ch chan Record IgnoreEmptyRow bool IgnoreIllegalRow bool NumEmptyRows []int // rows of emtpy rows NumIllegalRows []int // rows of illegal rows // contains filtered or unexported fields }
CSVReader is
func (*CSVReader) Read ¶ added in v0.27.0
func (csvReader *CSVReader) Read(opt ReadOption)
Run begins to read
type Config ¶
type Config struct { Verbose bool NumCPUs int Delimiter rune OutDelimiter rune // QuoteChar rune CommentChar rune LazyQuotes bool Tabs bool OutTabs bool NoHeaderRow bool NoOutHeader bool ShowRowNumber bool OutFile string IgnoreEmptyRow bool IgnoreIllegalRow bool }
Config is the struct containing all global flags
type ReadOption ¶ added in v0.27.0
type ReadOption struct { FieldStr string FieldStrSep string FuzzyFields bool IgnoreFieldCase bool DoNotAllowDuplicatedColumnName bool UniqColumn bool // deduplicate columns matched by multiple fuzzy column names AllowMissingColumn bool // allow missing column BlankMissingColumn bool ShowRowNumber bool Verbose bool }
type Record ¶ added in v0.27.0
type Record struct { Line int // line number, if the original file contains blank lines, the number would be inaccurate. Row int // the row number, header row skipped Err error IsHeaderRow bool // is current record the header row SelectWithColnames bool // wether user use colnames to select fields All []string Fields []int // selected fields Selected []string // selected columns }
Record is a CSV/TSV record
Source Files ¶
- add-header.go
- box.go
- cat.go
- comb.go
- concat.go
- corr.go
- csv.go
- csv2json.go
- csv2md.go
- csv2rst.go
- csv2tab.go
- csv2xlsx.go
- cut.go
- del-header.go
- del-quotes.go
- dim.go
- filter.go
- filter2.go
- fix-quotes.go
- fix.go
- fmtdate.go
- fold.go
- freq.go
- gather.go
- genautocomplete.go
- grep.go
- head.go
- header.go
- helper.go
- hist.go
- inter.go
- join.go
- line.go
- logging.go
- mutate.go
- mutate2.go
- ncol.go
- nrow.go
- plot.go
- pretty.go
- rename.go
- rename2.go
- replace.go
- root.go
- round.go
- sample.go
- sep.go
- sort.go
- space2tab.go
- split.go
- splitxlsx.go
- spread.go
- summary.go
- tab2csv.go
- transpose.go
- unfold.go
- uniq.go
- version.go
- watch.go
- xlsx2csv.go
Click to show internal directories.
Click to hide internal directories.