Live data from Hacker News

TextQL: Execute SQL Against CSV or TSV

github.com

11–20 of 95 posts

Re: TextQL: Execute SQL Against CSV or TSV

#11
post #8
post #5

In SQLite you can just do sqlite> .import myfile.csv mytable sqlite> select ... What does this tool give you that SQLite doesn't do out of the box?

From the README: Key differences between textql and sqlite importing sqlite import will not accept stdin, breaking unix pipes. textql will happily do so. textql supports quote escaped delimiters, sqlite does not. textql leverages the sqlite in memory database feature as much as possible and only touches disk if asked.

But it is SQLite under the covers? A better title then would be an SQLite wrapper for use in shell pipelines.

Re: TextQL: Execute SQL Against CSV or TSV

#14
post #11
post #8

Earlier quoted context omitted.

From the README: Key differences between textql and sqlite importing sqlite import will not accept stdin, breaking unix pipes. textql will happily do so. textql supports quote escaped delimiters, sqlite does not. textql leverages the sqlite in memory database feature as much as possible and only touches disk if asked.

But it is SQLite under the covers? A better title then would be an SQLite wrapper for use in shell pipelines.

That's a silly complaint. It's a tool powered by SQLite. Under your extended definition, tools like web browsers (which use SQLite to power various things) would be SQLite wrappers.

Re: TextQL: Execute SQL Against CSV or TSV

#15
post #10

If you work with CSV a lot, then also check out xsv, "a command line program for indexing, slicing, analyzing, splitting and joining CSV files", from Andrew Gallant (burntsushi of Go and Rust fame): https://github.com/BurntSushi/xsv

Another great tool to wrangle csv file is miller

http://johnkerl.org/miller/doc/

Re: TextQL: Execute SQL Against CSV or TSV

#16

This looks very simple and easy to use. Are there any differences with using this instead of CSVKit? https://csvkit.readthedocs.io/en/1.0.3/ It includes a tool called csvsql. Example usage - csvsql --query "select name from data where age > 30" data.csv > new.csv

Python's pandas library can also do sql-like queries against csv data.

https://pandas.pydata.org/pandas-docs/stable/comparison_with...

Re: TextQL: Execute SQL Against CSV or TSV

#17
PostgreSQL does this out of the box with :

  CREATE EXTENSION file_fdw;
  CREATE SERVER import FOREIGN DATA WRAPPER file_fdw;
  CREATE FOREIGN TABLE foo (
    col1 text,
    col2 text,
    ...
  ) SERVER import 
  OPTIONS ( filename '/path/to/foo.csv', format 'csv' );
  SELECT col1 FROM foo WHERE col2='x';

Re: TextQL: Execute SQL Against CSV or TSV

#19
post #17

PostgreSQL does this out of the box with : CREATE EXTENSION file_fdw; CREATE SERVER import FOREIGN DATA WRAPPER file_fdw; CREATE FOREIGN TABLE foo ( col1 text, col2 text, ... ) SERVER import OPTIONS ( filename '/path/to/foo.csv', format 'csv' ); SELECT col1 FROM foo WHERE col2='x';

... and with dozens of other data sources:

https://wiki.postgresql.org/wiki/Foreign_data_wrappers

Re: TextQL: Execute SQL Against CSV or TSV

#20
post #11

Earlier quoted context omitted.

But it is SQLite under the covers? A better title then would be an SQLite wrapper for use in shell pipelines.

That's a silly complaint. It's a tool powered by SQLite. Under your extended definition, tools like web browsers (which use SQLite to power various things) would be SQLite wrappers.

I don't see it as a complaint but as a piece of feedback and if you're the author then you may want to revisit your attitude.
Post reply on HN