On 2015-01-28 10:12, alb wrote: > I've a document structure which is extremely simple and represented > on a spreadsheet in the following way (a made up example): > > subsystem | chapter | section | subsection | subsubsec | > A | | | | | > | func0 | | | | > | |interface| | | > | |latency | | | > | |priority | | | > | func1 | | | | > | |interface| | | > | |latency | | | > | |priority | | | > > And I'd like to get a tree like this: > > A > +-------> func0 > | +---> interface > | +---> latency > | \---> priority > \-------> func1 > +---> interface > +---> latency > +---> priority > > I know about the xlrd module to get data from excel
If I have to get my code to read Excel files, xlrd is usually my first and only stop. > Does anyone recommend any other path other than scripting through > these two modules? Well, if you export from Excel as CSV, you can use the "csv" module in the standard library. This is actually my preferred route because it prevents people (coughclientscough) from messing up the CSV file with formatting, joined cells, and other weirdnesses that can choke my utilities. > Is there any more suitable module/example/project out there that > would achieve the same result? I don't believe there's anything that will natively do the work for you. Additionally, you'd have to clarify what should happen if two rows in the same section had different sub-trees but the same content/name. Based on your use-case (LaTex export using these as headers) I suspect you'd want a warning so you can repair the input and re-run. But it would be possible to default to either keeping or squashing the duplicates. > p.s.: I'm not extremely proficient in python, actually I'm just > starting with it! Well, you've come to the right place. Most of us are pretty fond of Python here. :-) -tkc -- https://mail.python.org/mailman/listinfo/python-list