Abstract Table Library

In the spirit of the standard Unix utilites (like cat, grep, cut, etc.), this library creates an abstraction over tabular data. The library implements a series of drivers for sources with different encodings that act like sequences.

Command Line Utilities

atcat


# dump a postgres table to the console (default is tab delimited)
atcat dbi://pg/localhost/database_name/table_name

# export a table to a tab file:
atcat dbi://pg/localhost/database_name/table_name tab://table_name.tab

# you can omit the schema for files, the schema will be guessed based on the file extension
atcat dbi://pg/localhost/database_name/table_name table_name.tab

# dump to csv
atcat dbi://pg/localhost/database_name/table_name csv://table_name.csv
# you can omit the scehma
atcat dbi://pg/localhost/database_name/table_name table_name.csv

# convert from csv to tab
atcat csv://some-file.csv tab://some-file.tab

atcat some-file.csv some-file.tab

# convert form csv to pipe
atcat csv://some-file.csv 'tab://some-file.tab?col_sep=|'

atview


atview tab://some-file.tab | less
atview csv://some-file.csv | less
atview dbi://pg/localhost/database_name/table_name | less
# view a list of tables:
atview dbi://pg/localhost/database_name | less

atcat

Limitations: only implemented ‘driver’ is dbi. Only supported output port is stdout as tab delimited.


atcat dbi://user:pass@Pg/localhost/db_name/table_name | atview | less

atgrep

Filter a table source by passing an expression, which has access to the record via the var r:


atgrep -e 'r[0] == "this"' test/fixtures/files/file1.csv | atview

Suported Drivers

tab

Native Ruby for now.

col_sep

Defaults to a tab character.

csv

Via the FasterCSV ruby gem.

col_sep

Override the default ‘,’ column seperator.

quote_char

Override the default quote_char (").

License

Authors

Kyle Burton <[email protected]>