Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to be able to easily show a simple text-only representation of a spreadsheet (Calc or Excel) via the command line (so I can pipe that output to usual Linux text manipulation tools). Is there a tool or quick way of accomplishing that?

Here's an example of how such output could look like:

A       B       C       D       E  
Sales   Month  
1000    Jan  
5000    Feb
8000    Mar
2300    Total
share|improve this question
    
Does it have to open .ods? There is this, link but I've never used it. –  Matt Barnes May 11 '12 at 2:17

2 Answers 2

up vote 1 down vote accepted

You could use unoconv to transform the Calc sheet into csv. But unoconv seems to be quite instable, i didn't manage to get it working on a simple ods (calc) file.

A better choice is jodconverter. It's available in universe, so you can install it using apt. Jodconverter requires an instance of openoffice running and listening on port 8100.

To "manually" convert this sheet

sheet

from ods to csv:

$ soffice -headless -accept="socket,port=8100;urp;"
$ jodconverter Untitled1.ods Untitled1.csv

The resulting csv will look like this:

$ cat Untitled1.csv 
"A","B","C","D"
34,68,23,3
34234,68468,34,1
3423,6846,34,34535

If you don't need the table structure but just the contents for indexing purposes, take a look at odt2txt. It seems to be able to handle ods files, too, but it won't preserve the table structure. It doesn't require q soffice process running. With the sheet shown above, you will receive the following output:

$ odt2txt Untitled1.ods 

A

B

C

D

34

23

3

34234

3

34

1

3423

234

34

34535
share|improve this answer
    
I has hoping to be able to show it as tabular data _directly (without an intermediate .csv), but there's probably no tool for that. Thanks for the answer! –  Lance Herbert May 12 '12 at 15:40

Sure. It's called, save as CSV and use cat.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.