In the beginning, there should usually be a requirements analysis. What are typical requirements surrounding my use of CSV?
- I mostly want to add new items. Sometimes there are fields which are identical with the previous entry.
- I like to have a classifc "form" view of each row, that is, seeing a row as "Field name: Content\nField name: Content" rather than "Content;Content;Content".
- Oh, did I mention, I like the presence of field names? My CSV files usually have a first row just for the field names.
- I don't want to be pinned to one given seperator symbol. Even if this means I have to enter it before each usage.
- I want to search for contents in the file, regardless of fields (yep, that one may kick my ass one day. But that day is yet to come...)
- There are very few times I want to change things and even less situations in which I want to drop a line completely. However, they do exist.
- I want to edit CSV files using a terminal -- my old serial Siemens TC20 serial terminal, that is. Thus, no GUI, thank you.
- I can live with the risk of the seperator char being part of a value. I don't want the endeavour of solving that problem. Better just use a sane seperation char...
CSVEDIT is published under the two-clause BSD license. Short version: Do whatever you feel like, including selling it and making millions on my back -- but do not remove the notice that I wrote this specific piece of code. Not in the license: If you do so (make millions of my back, not remove the notice), invite me for a drink.
You can download CSVEDIT here down/csvedit.pl. To run, issue
perl csvedit.pl somecsvfile.csvas I did not include a shebang-line. I did so on purpose: On my system, perl is
/usr/bin/perl. I'm not sure, your perl interpreter shares this locatiuon.
CSVEDDIT is mostly improvised and far away from being a masterpiece of perl programming art. It's written in a way to work on my system -- there is no guarentee for it to be runnable or functional on your system... it depends at least on a VT100 compatible console and the stty utility.