If 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-...
Ah, I thought you were going to link to the fascinating skunkworks Log Parser tool https://www.microsoft.com/en-us/download/details.aspx?id=246... Wonder if it still runs on Windows 10?
Q: Run SQL Directly on CSV Files
21–30 of 102 posts
Re: Q: Run SQL Directly on CSV Files
#22The perl CPAN module DBD::CSV also lets you do this. It was started in 1998 and still gets updates.
Re: Q: Run SQL Directly on CSV Files
#23If 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-...
Ah, I thought you were going to link to the fascinating skunkworks Log Parser tool https://www.microsoft.com/en-us/download/details.aspx?id=246... Wonder if it still runs on Windows 10?
Re: Q: Run SQL Directly on CSV Files
#24Real-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?
All of your “horrors” seem...correct? Its comma delimited, so anything that is between two commas should be parsed without issue; if it’s a string with a comma in it, and unquoted, you simply have a broken csv file. If its quoted, than anything until the next (unescaped) quote is fine, including commas Unless you’re trying to parse csv files with regexes, none of those should be difficult, or even unexpected, to hand…
Re: Q: Run SQL Directly on CSV Files
#25Re: Q: Run SQL Directly on CSV Files
#26Real-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?
Import-CSV .\file.csv | Export-CSV .\file.csv -NoTypeInformation -Encoding UTF8
Re: Q: Run SQL Directly on CSV Files
#27I'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
#28And there are drivers for everything from PostgreSQL and Oracle to text files and the Azure WMI.
Re: Q: Run SQL Directly on CSV Files
#29https://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...