How to output a spreadsheet as plain text in the terminal

I’ve got a simple LibreOffice Calc spreadsheet I’d like to view directly in the terminal. The contents look like this when it is exported as CSV:

name,created,size
Abc,01/29/70,42
Def,04/10/71,43
Ghi,04/11/72,20

I’d like to output it in the terminal so I could manipulate it as plain text. I’m imagining something like:

libreoffice --csv test.ods \
  | mlr --csv --opprint --barred filter '${name} == "Abc"

Which, for the CSV data above, would output:

+------+----------+------+
| name | created  | size |
+------+----------+------+
| Abc  | 01/29/70 | 42   |
+------+----------+------+

That’s just one example I could think of, using Miller.

I tried libreoffice --cat test.ods but it prints out:

Warning: failed to launch javaldx - java may not function correctly
Error: Please verify input parameters... (SfxBaseModel::impl_store <file:///tmp/lu24993351ub1yt.tmp/lu24993351ub1yv.tmp> failed: 0xc10(Error Area:Io Class:Write Code:16) ./sfx2/source/doc/sfxbasemodel.cxx:3202 ./sfx2/source/doc/sfxbasemodel.cxx:1775)

I’m using LibreOffice 7.3.7.2 30(Build:2) on 64-bit Ubuntu 22.04 LTS desktop.

Got it:

libreoffice --convert-to csv test.ods
mlr --csv --opprint --barred filter '${name} == "Abc"' < test.csv

See:

And these (I’m not yet allowed to add a lot of clickable links):

https://ask.libreoffice.org/t/cli-convert-ods-to-csv-with-semicolon-as-delimiter/5021

https://wiki.documentfoundation.org/ReleaseNotes/7.2#Document_Conversion

https://github.com/unoconv/unoconv - 3rd party tool

1 Like