LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-10-2016, 11:07 AM   #1
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
create multi-tab ods from tab delimited files


[aix]
i am in the midst of editing some ms-excel macros (yuk !) and i just realized that the latest version of microsoft excel now supports open-document-spreadsheets.

does anyone have any pointers on how to generate ods's from the command-line ?
 
Old 10-10-2016, 12:12 PM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Hi!

You can manipulate ODS using python, take a look at pyexcel-ods3 for instance. For ODF there is odfpy.

Last edited by firstfire; 10-10-2016 at 12:13 PM.
 
1 members found this post helpful.
Old 10-10-2016, 12:21 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Interesting. I was under the impression that M$ only supported it in name only and that it would still break a lot of documents.

Be that as it may, you could just generate tab-delimited text files and name them .csv and import them one spreadsheet tab at a time.

Or you might look at something like this:
http://search.cpan.org/dist/OpenOffi...ODoc/Intro.pod
Perl is pretty quick to work with and to get something usable.
 
Old 10-10-2016, 01:24 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by firstfire View Post
Hi!

You can manipulate ODS using python, take a look at pyexcel-ods3 for instance. For ODF there is odfpy.
pyexcel-ods3 looks good but unfortunately my aix installation doesnt have python installed.
Quote:
Originally Posted by Turbocapitalist View Post
Interesting. I was under the impression that M$ only supported it in name only and that it would still break a lot of documents.

Be that as it may, you could just generate tab-delimited text files and name them .csv and import them one spreadsheet tab at a time.

Or you might look at something like this:
http://search.cpan.org/dist/OpenOffi...ODoc/Intro.pod
Perl is pretty quick to work with and to get something usable.
i do have perl but not use OpenOffice::OODoc;. still reading...

Last edited by schneidz; 10-10-2016 at 01:33 PM.
 
Old 10-10-2016, 01:58 PM   #5
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Quote:
Originally Posted by schneidz View Post
pyexcel-ods3 looks good but unfortunately my aix installation doesnt have python installed.
i do have perl but not use OpenOffice::OODoc;. still reading...
Then you may unzip some .ods file and hack content.xml (see description of file format here and in references), then compress again. An XML parser / XSLT interpreter would help.
 
1 members found this post helpful.
Old 07-24-2017, 11:06 AM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Original Poster
Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by firstfire View Post
Then you may unzip some .ods file and hack content.xml (see description of file format here and in references), then compress again. An XML parser / XSLT interpreter would help.
hi, this is what i came up with:
Code:
mkdir tmp-schneidz
for ods in *.tab
do
 lines=`grep -c . $ods`
 echo -e '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\015\012' > tmp-schneidz/content.xml
 echo -e '<office:document-content xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:msoxl="http://schemas.microsoft.com/office/excel/formula"><office:font-face-decls><style:font-face style:name="Calibri" svg:font-family="Calibri"/></office:font-face-decls><office:automatic-styles><style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N0"/><style:style style:name="ce2" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N30"><style:table-cell-properties fo:background-color="#B8CCE4"/><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/></style:style><style:style style:name="ce3" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N30"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/></style:style><style:style style:name="ce4" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N0"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/></style:style><style:style style:name="ce5" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N30"/><style:style style:name="co1" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.29645833333333cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co2" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="2.19604166666667cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co3" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="2.06375cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co4" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.349375cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co5" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="3.28083333333333cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co6" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="2.51354166666667cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co7" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="3.96875cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co8" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.37583333333333cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co9" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.42875cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co10" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.53458333333333cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co11" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="0.79375cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co12" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="0.978958333333333cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co13" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.508125cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co14" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.40229166666667cm" style:use-optimal-column-width="true"/></style:style><style:style style:name="co15" style:family="table-column"><style:table-column-properties fo:break-before="auto" style:column-width="1.69333333333333cm"/></style:style><style:style style:name="ro1" style:family="table-row"><style:table-row-properties style:row-height="15pt" style:use-optimal-row-height="true" fo:break-before="auto"/></style:style><style:style style:name="ta1" style:family="table" style:master-page-name="mp1"><style:table-properties table:display="true" style:writing-mode="lr-tb"/></style:style></office:automatic-styles><office:body><office:spreadsheet><table:calculation-settings table:case-sensitive="false" table:search-criteria-must-apply-to-whole-cell="false"/><table:table table:name="shh-ods-parser" table:style-name="ta1"><table:table-column table:style-name="co1" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co2" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co3" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co4" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co5" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co6" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co7" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co8" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co9" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co10" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co11" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co12" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co13" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co14" table:default-cell-style-name="ce1"/><table:table-column table:style-name="co15" table:number-columns-repeated="16370" table:default-cell-style-name="ce1"/><table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" table:style-name="ce2"><table:cell-range-source table:name="Connection1" table:last-column-spanned="14" table:last-row-spanned="11" xlink:href="C:\stuff\aug\c2\sr-9992-1543\sr-a9992-1543-cycle.xls"/><text:p>PREFIX</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>hello</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>world</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>SEGNO</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>l33t</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>h4x0rz</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>FILEID</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>chun-li</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>STATUS</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>REASON</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>akuma</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce2"><text:p>TYPE</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce3"><text:p>SOURCE</text:p></table:table-cell><table:table-cell office:value-type="string" table:style-name="ce3"><text:p>CTL-NO</text:p></table:table-cell><table:table-cell table:number-columns-repeated="16370" table:style-name="ce4"/></table:table-row>' > tmp-schneidz/content.schneidz
 awk -F '\t' '{print "<table:table-row table:style-name=\"ro1\"> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$1"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$2"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$3"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$4"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$5"<text:s text:c=\"3\"/></text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$6"<text:s text:c=\"8\"/></text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$7"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$8"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$9"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$10"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$11"<text:s text:c=\"3\"/></text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$12"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$13"</text:p></table:table-cell> \
                      <table:table-cell office:value-type=\"string\" table:style-name=\"ce5\"><text:p>"$14"</text:p></table:table-cell> \
                      <table:table-cell table:number-columns-repeated=\"16370\"/></table:table-row>"}' $ods >> tmp-schneidz/content.schneidz
 echo '<table:table-row table:number-rows-repeated="'  >> tmp-schneidz/content.schneidz
 expr 1048575 - $lines >> tmp-schneidz/content.schneidz
 echo '" table:style-name="ro1"><table:table-cell table:number-columns-repeated="16384"/></table:table-row></table:table></office:spreadsheet></office:body></office:document-content>' >> tmp-schneidz/content.schneidz
 cat tmp-schneidz/content.schneidz | tr -d '\n' >> tmp-schneidz/content.xml
 cp /etc/ods/manifest.xml /etc/ods/meta.xml /etc/ods/mimetype /etc/ods/styles.xml tmp-schneidz
 cd tmp-schneidz
 rm content.schneidz
 pkzip $ods; mv \"$ods\".zip ../`echo $ods | sed s/.tab/.ods/`
 cd ..
 rm -rf $ods tmp-schneidz/
done
the cr-lf's are very sensitive and would result in a workbook is corrupted error in ms-excel (havent tried it in open-office). still trying to figure out how to combine certain worksheets into the same spreadsheet.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create tab delimited file with header SuKHI Linux - Newbie 2 10-29-2015 09:13 PM
Split tab delimited files javaer Linux - Newbie 2 02-03-2014 02:28 PM
searching pattern in tab delimited file using grep vaibhavs17 Programming 5 03-05-2010 01:02 AM
Working with Tab-Delimited files shiroh_1982 Linux - Newbie 5 06-02-2006 04:08 AM
Parsing a tab delimited text file jajanes Programming 9 08-08-2003 10:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration