csv-awk

Copyright (C) 2025 Jonathan Lamothe jonathan@jlamothe.net

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Executive Summary

These are quick and dirty Python scripts I threw together to facilitate manipulating CSV files with AWK. They are heavily inspired by csvquote. I just didn't want to have to install go on a machine to use it. I wrote this one in Python because that's very likely to already be present on most any modern UNIX-ey system.

It provides two scripts: csv-reader.py and csv-writer.py which read and write CSV files respectively (converting to and from a simpler format). Both read from standard input and write to standard output. The format they convert the CSV to/from works as follows:

  • Each row is represented as a single line of text.
  • Cells are separated by tab characters.
  • Certain special characters within the cells are substituted for other values as follows:
    • Newlines become ~n.
    • Carriage returns become ~r.
    • Tabs become ~t.
    • Tildes (~) become ~!.
  • All other characters remain unchanged.

Disclaimer

I haven't seriously looked at Python in over a decade and I hacked this together in like 30 minutes. Don't go looking for the most well put-together code you've ever seen. It gets the job done though.

Description
Tools for working with CSV files in AWK
Readme 47 KiB
Languages
Python 100%