3 ms·
Ha. I was just thinking how useful it would be to have the awk programming language available in a tool that natively understood csv files. Suddenly that seems
by helper 8y ago
Ha. I was just thinking how useful it would be to have the awk programming language available in a tool that natively understood csv files. Suddenly that seems a lot more doable!
- dbro 8y agoYou might want to check out https://github.com/dbro/csvquote https://github.com/dbro/csvquote which helps awl and other text tools handle csv files which have quoted strings as values.
- helper 8y agoIf I'm going to preprocess before invoking awk I think I'd rather switch the separators to use ascii record/unit separator values than to replace the content of the actual fields.
- benhoyt 8y agoInteresting point. I've though that AWK should have a mode where it does proper quote parsing of CSV files. Maybe I'll add a -csv option for that (or just have it do it automatically when the FS is ',' -- though that wouldn't be backwards compatible).
- helper 8y agoIf you add a -csv I would use it!
- vram22 8y agoYou probably know it already, but in case not, the CSV format is not fully standardized, and so there are variations. So you might have to handle those to provide better support of the feature, if you implement it. https://en.wikipedia.org/wiki/Comma-separated_values https://en.wikipedia.org/wiki/Comma-separated_values For example, csv.reader in Python's csv module in the stdlib, has a dialect argument, due to this. https://docs.python.org/2/library/csv.html https://docs.python.org/2/library/csv.html https://docs.python.org/3/library/csv.html https://docs.python.org/3/library/csv.html
- jrumbut 8y agoPerhaps deal with quotes strings generally, and then quoted strings mode with FS=, is CSV mode, and that quoted string functionality is available elsewhere (and maybe also for output). Less intuitive maybe for beginners but more generally useful?