$ sqlite3
sqlite3> .mode csv
sqlite3> .import foo.csv foo
sqlite3> SELECT * FROM foo WHERE bar = 'baz'; -- you get the gist...
(a bunch of rows)
Q seems to be much easier to use (and certainly easier to remember), but I've always found it handy to have the full power of SQL at my fingertips when needing to do a bunch of CSV manipulations.Q: Run SQL Directly on CSV Files
41–50 of 102 posts
Re: Q: Run SQL Directly on CSV Files
#42Re: Q: Run SQL Directly on CSV Files
#43I've never heard of this before, but it reminded me of this other command line tool for wrangling csv files in a cli. This tool makes use of SQL syntax much more than xsv, so there isn't 100% overlap here. https://github.com/BurntSushi/xsv
Re: Q: Run SQL Directly on CSV Files
#44“Any file is a database if you awk hard enough.” —Bryan Horstmann-Allen https://twitter.com/neilkod/status/914217352564137984 Furthermore, no thread on CSV files can be complete without mentioning this infamous bit of fact-trolling: the ASCII standard has had unit- and record-delimiters baked into it from the beginning. https://ronaldduncan.wordpress.com/2009/10/31/text-file-form...
We just need an rcat to print them clearly.
Re: Q: Run SQL Directly on CSV Files
#45If you're on Windows, you've had the ability to do this for Quite Some Time®: https://support.microsoft.com/en-us/help/850320/creating-an-...
Re: Q: Run SQL Directly on CSV Files
#46I've never heard of this before, but it reminded me of this other command line tool for wrangling csv files in a cli. This tool makes use of SQL syntax much more than xsv, so there isn't 100% overlap here. https://github.com/BurntSushi/xsv
Thanks! xsv is new to me. I love Andrew Gallant's ripgrep(rg) grepping cmd tool.
Re: Q: Run SQL Directly on CSV Files
#47Ya know how some people want everything to be vim after they use it? I'm surprised more people haven't done that with other tools.
Re: Q: Run SQL Directly on CSV Files
#48Re: Q: Run SQL Directly on CSV Files
#49Real-world CSV files generally contain some or all of the following horrors: - some strings enclosed in speechmarks, but some not - empty fields - speechmarks within strings - commas within strings - carriage returns within strings How does Q do up against a CSV file with those traits?
Re: Q: Run SQL Directly on CSV Files
#501: https://dev.mysql.com/doc/refman/8.0/en/csv-storage-engine.h...