3 ms·
Not on “computer” but some such in your pipeline should be good enough more often than not? awk -v OFS='\t' '{$1=$1; print}' | column -t
by musha68k 3y ago
Not on “computer” but some such in your pipeline should be good enough more often than not?
awk -v OFS='\t' '{$1=$1; print}' | column -t
- cowsandmilk 3y agomany csv data sets cannot be handled by awk due to csv supporting things like commas inside fields, newlines inside fields, etc. Your solution would also fall over for any tabs within fields. Plenty of tools out there support RFC 4180 CSV files as well as common csv variants. And these tools have been around for a decade and have suites of cli commands that can be piped together, just speaking "CSV" as a format rather than pure text streams.
- musha68k 3y agoGood points on using proper CSV tooling 100%; so that’s why the disclaimer “more often than not” BTW I just realized that I was omitting the field separator ‘-F,’ actually. For those pesky nested commas from top off simplistic text hat still I’d go back to sed for fun and potential profit: sed 's/","/"\t"/g; s/^"/"\t/; s/"$//; s/,,/, ,/g' | column -t Not elegant nor hands-off and might be missing something else; def needs the right data / volume and fiddling as we know ymmv; can get unwieldy quickly etc etc TLDR; use column -t when applicable
- prudentpomelo 3y agoAwk now supports a `--csv` flag for processing csv's. https://github.com/onetrueawk/awk/blob/master/README.md https://github.com/onetrueawk/awk/blob/master/README.md