At Mon, 27 Nov 2017 11:46:36 -0800 (PST) Alexandru <
alexandr...@meshparts.de> wrote:
>
> Hi,
>
> I have a bunch of Excel tables exported from Salesforce.
> This is like a data dump. Everything ever made in Salesforce is in those Excel tables.
>
> I want to use Tcl to inquire things saved in those Excel tables.
>
> What would be the quick and dirty solution for this task?
Using oocalc (or localc) at the command line:
oocalc --headless --convert-to csv table.xlsx
OR use oocalc/localc or Excel itself and "Save As" a csv file using the point
and click interface.
Then you can use the struct::matrix and the csv packages from tcllib:
package require struct::matrix
package require csv
set fp [open "table.csv" r]
set headers [::csv::split [gets $fp]]
set m [::struct::matrix]
$m add columns [llength $headers]
::csv::read2matrix $fp $m
close $fp
At this point all of your data is in $m
Read the man page for struct::matrix:
man matrix
for info on how to do stuff with the matrix (eg access cells, etc.).
>
> Should I first import Excel data into a database such as SQL Light or should I do this in pure Tcl, perhaps using dicts?
>
> Thanks
> Alexandru
>
--
Robert Heller --
978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services