Score:0

CSV tools for terminal?

in flag

I'm using Ubuntu 18.04 and above, both desktop and server, and looking for terminal tools to query / write to large CSV file efficiently, and also easy to interact (few simple commands or commands that resemble SQL query language).

What would you recommend?

bac0n avatar
cn flag
[Miller](https://github.com/johnkerl/miller/)
hr flag
If you want to use *actual* SQL queries, then you can use `csvsql` from [the csvkit package](https://packages.ubuntu.com/bionic/csvkit)
Score:3
sd flag

One such tool is csvtool, bundled with Ubuntu 18.04 LTS to 22.10, at least.

NB: Recommending awk (as top response in the first answer) is a terrible idea. Indeed, awk allows convenient splitting at any defined separator symbol, but if this is ,, it is very likely to get distracted by any , used within CSV values, so you cannot guarantee you get the right columns. The same is true for other low-level tools such as cut, etc. There are good reasons to work with these (e.g., cross-platform availability), but if you're going that route, better use TSV rather than CSV files to avoid the field separator issue.

Score:1
cn flag

An excellent suit of tools to clean and process csv files is :

https://csvkit.readthedocs.io/en/latest/

The link provides installation guides and tutorials to get you started.

Pizza avatar
in flag
I would prefer to avoid 'awk', although it may help doing basic queries - manipulating data in CSV files using it is quite inconvenient (for me, at least).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.