sudo apt install python3-odf
sudo python3 -m pip install pyexcel-ods

In [2]:
from odf.opendocument import OpenDocumentSpreadsheet, load

In [3]:
doc = load('data/frame-6.ods')

In [4]:
for e in doc.spreadsheet.childNodes:
    print(str(e))


NODEIDXYZA05000.1B040005000C800040005000D800005000
MEMBERIDNODEJNODEKABABBCBCDCDC
NODEIDC0C1C2AFXFYMZDFXFY
MEMBERIDRELEASE
MEMBERIDSIZEIXABCW460x10648800000013500ABW310x9722200000012300DC
LOADNODEIDDIRNFWindBFX-200000
LOADMEMBERIDTYPEW1W2ABCLiveBCUDL-50LiveBCPL-2000005000
LOADNODEIDDIRNDELTA
CASELOADFACTOROneLive1OneWind1


In [8]:
from pyexcel_ods import get_data
data = get_data("data/frame-6.ods")
data


Out[8]:
OrderedDict([('Image', [[]]),
             ('nodes',
              [['NODEID', 'X', 'Y', 'Z'],
               ['A', 0, 0, 5000.1],
               ['B', 0, 4000, 5000],
               ['C', 8000, 4000, 5000],
               ['D', 8000, 0, 5000]]),
             ('members',
              [['MEMBERID', 'NODEJ', 'NODEK'],
               ['AB', 'A', 'B'],
               ['BC', 'B', 'C'],
               ['DC', 'D', 'C']]),
             ('supports',
              [['NODEID', 'C0', 'C1', 'C2'],
               ['A', 'FX', 'FY', 'MZ'],
               ['D', 'FX', 'FY']]),
             ('releases', [['MEMBERID', 'RELEASE']]),
             ('properties',
              [['MEMBERID', 'SIZE', 'IX', 'A'],
               ['BC', 'W460x106', 488000000, 13500],
               ['AB', 'W310x97', 222000000, 12300],
               ['DC']]),
             ('node_loads',
              [['LOAD', 'NODEID', 'DIRN', 'F'], ['Wind', 'B', 'FX', -200000]]),
             ('member_loads',
              [['LOAD', 'MEMBERID', 'TYPE', 'W1', 'W2', 'A', 'B', 'C'],
               ['Live', 'BC', 'UDL', -50],
               ['Live', 'BC', 'PL', -200000, '', 5000]]),
             ('support_displacements', [['LOAD', 'NODEID', 'DIRN', 'DELTA']]),
             ('load_combinations',
              [['CASE', 'LOAD', 'FACTOR'],
               ['One', 'Live', 1],
               ['One', 'Wind', 1]])])

In [9]:
import json
print(json.dumps(data))


{"Image": [[]], "nodes": [["NODEID", "X", "Y", "Z"], ["A", 0, 0, 5000.1], ["B", 0, 4000, 5000], ["C", 8000, 4000, 5000], ["D", 8000, 0, 5000]], "members": [["MEMBERID", "NODEJ", "NODEK"], ["AB", "A", "B"], ["BC", "B", "C"], ["DC", "D", "C"]], "supports": [["NODEID", "C0", "C1", "C2"], ["A", "FX", "FY", "MZ"], ["D", "FX", "FY"]], "releases": [["MEMBERID", "RELEASE"]], "properties": [["MEMBERID", "SIZE", "IX", "A"], ["BC", "W460x106", 488000000, 13500], ["AB", "W310x97", 222000000, 12300], ["DC"]], "node_loads": [["LOAD", "NODEID", "DIRN", "F"], ["Wind", "B", "FX", -200000]], "member_loads": [["LOAD", "MEMBERID", "TYPE", "W1", "W2", "A", "B", "C"], ["Live", "BC", "UDL", -50], ["Live", "BC", "PL", -200000, "", 5000]], "support_displacements": [["LOAD", "NODEID", "DIRN", "DELTA"]], "load_combinations": [["CASE", "LOAD", "FACTOR"], ["One", "Live", 1], ["One", "Wind", 1]]}

In [10]:
data['members']


Out[10]:
[['MEMBERID', 'NODEJ', 'NODEK'],
 ['AB', 'A', 'B'],
 ['BC', 'B', 'C'],
 ['DC', 'D', 'C']]

In [11]:
# convert ints to floats

In [12]:
data['nodes']


Out[12]:
[['NODEID', 'X', 'Y', 'Z'],
 ['A', 0, 0, 5000.1],
 ['B', 0, 4000, 5000],
 ['C', 8000, 4000, 5000],
 ['D', 8000, 0, 5000]]

In [13]:
[type(x) for x in data['nodes'][1]]


Out[13]:
[str, int, int, float]

In [14]:
[ float(x) if type(x) is int else x for x in data['nodes'][1]]


Out[14]:
['A', 0.0, 0.0, 5000.1]

In [ ]: