A simple utility to extract columns from CSV.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Darshil Chanpura c5ff12a123 Fix: missing usage of separator in extract command 1 month ago
.gitignore Initial Commit 9 months ago
LICENSE Added LICENSE 1 month ago
README.md Go mod change and minor additions to README 6 months ago
go.mod Updated go.mod 1 month ago
go.sum Updated go.mod 1 month ago
main.go Fix: missing usage of separator in extract command 1 month ago

README.md

Extractor

A simple utility to extract columns from CSV.

Usage and Examples

There are mainly two commands as of now, list and extract.

Usage: extractor <command>

Flags:
  -h, --help           Show context-sensitive help.
  -v, --verbose        Enable debug mode
      --sep="comma"    Separator to be used.

Commands:
  list       List CSV Columns
  extract    Extracts columns from CSV

Run "extractor <command> --help" for more information on a command.

List

This command helps to list the columns available.

Usage: extractor list <input>

List CSV Columns

Arguments:
  <input>    Input filename

Flags:
  -h, --help           Show context-sensitive help.
  -v, --verbose        Enable debug mode
      --sep="comma"    Separator to be used.

Example:

$❯ extractor list eng.4.csv
* Round
* Date
* Team 1
* FT
* Team 2

Extract

This command will start extracting the columns from the input file to output file. If in debug mode, --count specifies the update frequency to show progress

Usage: extractor extract <input> <output> <columns> ...

Extracts columns from CSV

Arguments:
  <input>          Input filename
  <output>         Output filename
  <columns> ...    Columns to extract

Flags:
  -h, --help           Show context-sensitive help.
  -v, --verbose        Enable debug mode
      --sep="comma"    Separator to be used.

      --count=1000     Frequency to show progress

Example:

$❯ extractor extract eng.4.csv /dev/stdout "Team 1" "Team 2"
Team 1,Team 2
Barrow AFC,Stevenage FC
Bolton Wanderers FC,Forest Green Rovers FC
Bradford City AFC,Colchester United FC
Cambridge United FC,Carlisle United FC
Cheltenham Town FC,Morecambe FC
Walsall FC,Grimsby Town FC
Mansfield Town FC,Tranmere Rovers FC
Oldham Athletic AFC,Leyton Orient FC
Port Vale FC,Crawley Town FC
...

$❯ extractor extract eng.4.csv eng.4.teams.csv "Team 1" "Team 2" -v --count 10
Opening input file... eng.4.csv
Opening output file... eng.4.teams.csv
Starting extraction...
Extracted 553 records.
Finished.