Skip to content
Beta · version 0.6.1 · commands and the JSON format may still change.

CLI: tabalyst sample

Terminal window
tabalyst sample INPUT... --sample-method METHOD [OPTIONS]

Creates <stem>.sample.csv beside each CSV source, or in the folder of -d, without modifying the source. Choose exactly one size: --rows or --percent. See Tabalyst Sample.

OptionDescription
INPUT...One or more CSV files or non-recursive glob patterns (required)
--sample-method METHODRequired: first, last, random or stratified
--rows NNumber of data rows to select
--percent XPercentage of data rows to select, rounded up to a whole row. Exclusive with --rows
--field TEXTField that defines the strata, required by stratified
--seed NSeed that makes a random or stratified selection reproducible
-o, --output PATHOutput CSV filename, for a single input. Not with -d
-d, --output-dir PATHFolder for samples named <stem>.sample.csv
-c, --config PATHJSON configuration file
--delimiter TEXTOne-character CSV delimiter
--encoding TEXTCSV text encoding
-f, --forceReplace an existing sample file; a source is never replaced
--helpShow the options and exit
Terminal window
tabalyst sample customers.csv --sample-method first --rows 1000
tabalyst sample customers.csv --sample-method last --rows 1000
tabalyst sample customers.csv --sample-method random --percent 5 --seed 42
tabalyst sample customers.csv --sample-method stratified --field province --rows 1000 --seed 42
tabalyst sample customers.csv --sample-method first --rows 100 -o test.csv
tabalyst sample *.csv --sample-method random --percent 5 -d samples/
tabalyst sample data.csv --sample-method random --rows 100 --delimiter ";" --encoding cp1252

Sample accepts CSV files only; there is no Excel or JSON sample.

CodeWhen
0Every sample was written
1A sample could not be written
2Invalid options
4A source is missing, unreadable or invalid