Interactive console based CSV editor
Although spreadsheet applications for editing CSV files on the console used to be one of the earliest killer applications for personal computers, only few of them and even less documentation about them is still actively maintained.
After having done extensive search on the web, manpages and source code, I ended up with the following three applications that all have fundamental drawbacks:
- sc: abbrev. for spreadsheet calculator; nice tool with vi keybindings, but it does not put strings containing the delimiter into quotes when exporting to delimiter separated format and can't import csv files correctly, i.e. all numbers are interpreted as strings
- GNU oleo: doesn't seem to be actively maintained any longer since 2001 and there are therefore no packages for major linux distributions
- teapot: offers packages for various operating systems, but uses for example counter-intuitive naming for cells (numbers for row and column, i.e. 11 seems to be intended to be row 1, column 1) and superfluous code for FLTK GUI
Various Emacs modes also do not quote strings containing the delimiter well or are require much more typing for entering the scaffold of a table.
Therefore I would be very grateful for overcoming one of these drawbacks or any hints towards another console based CSV editor. It actually needn't do any calculations just editing cells or column- and rows.
A CSV editor is generally expected to recognize numbers as such, quote strings only when needed, allow delimiters within quoted strings, and not collapse empty cells. So, this on the screen
1 2 3
col-one col,three
col two
This is a long string. 1.23456789 3.14
should correlate to this in the file
1,2,3
col-one,,"col,three"
,"col two",
"This is a long string.",1.23456789,3.14
Oleo has not been maintained for several years. I installed an old package on a recent Debian system and found it to be awkward and very buggy. Operations take more than the usual number of keystrokes. All strings must be quoted and you have to do it manually. The CSV import filter cannot handle commas within strings. Long-precision numbers are not kept in their original form (e.g. 1.23456789 becomes 1.234567889999999). The process sometimes becomes runaway so that it can't be killed from the command line.
It seems that MacroCALC, Teapot, and SC are the only CLI spreadsheets still being maintianed.
MacroCALC can not cleanly import or export CSV files.
Teapot is a little unusual, but it is very easy to use and the manual is a quick read. Import/export of CSV is simple. It has two major quirks. First, while it does automatic quoting of strings, it always quotes all strings. Second, it will truncate/expand all decimal numbers to the default precision. The FLTK interface is operational, but it is buggy.
SC is fast and stable. It operates similarly to vi and is about as beginner-friendly. External programs are required to convert between SC format and CSV. The psc
tool (CSV -> SC only) is installed with SC and works like so:
cat file.csv | psc -k -d, | sc
After editing, save the file with the Put command, then use the ssconvert
utility (SC -> CSV only) that comes with Gnumeric:
ssconvert file.sc file.csv
I tried round-tripping a variety of things with psc
-ssconvert
and the process appears stable. Numbers and strings are handled correctly.
An alternative method for editing CSV files would be to use a text editor with an appropriate plugin. Both Emacs and Vim have them, though the Vim version is faster and had more features. These offer highlighting, column alignment, and block operations. I found both to be very slow and buggy.
scim is the best I've seen and can natively import csv and export csv.
https://github.com/andmarti1424/scim