Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84759

Re: parsing tree from excel sheet

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'tree': 0.05; 'messing': 0.09; 'prevents': 0.09; 'proficient': 0.09; 'rows': 0.09; 'scripting': 0.09; 'subject:parsing': 0.09; 'python': 0.11; '-tkc': 0.16; 'csv': 0.16; 'csv,': 0.16; 'fond': 0.16; 'formatting,': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'received:174.136': 0.16; 'subsection': 0.16; 'xlrd': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'module': 0.19; 'input': 0.22; 'preferred': 0.22; "i've": 0.25; 'chapter': 0.26; 'this:': 0.26; 'excel': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; 'repair': 0.31; 'anyone': 0.31; 'file': 0.32; 'interface': 0.32; "i'd": 0.34; 'subject:from': 0.34; 'but': 0.35; 'there': 0.35; 'joined': 0.36; 'library.': 0.36; 'charset:us- ascii': 0.36; 'possible': 0.36; 'should': 0.36; 'two': 0.37; 'received:10': 0.37; 'starting': 0.37; 'to:addr:python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'extremely': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'read': 0.60; 'most': 0.60; 'simple': 0.61; 'first': 0.61; 'you.': 0.62; "you've": 0.63; 'happen': 0.63; 'more': 0.64; 'different': 0.65; 'it!': 0.67; 'believe': 0.68; 'default': 0.69; 'export': 0.74; 'p.s.:': 0.84; 'route': 0.84; 'spreadsheet': 0.84
X-Sender-Id wwwh|x-authuser|tim@thechases.com
X-Sender-Id wwwh|x-authuser|tim@thechases.com
X-MC-Relay Neutral
X-MailChannels-SenderId wwwh|x-authuser|tim@thechases.com
X-MailChannels-Auth-Id wwwh
X-MC-Loop-Signature 1422454314886:2309033204
X-MC-Ingress-Time 1422454314886
Date Wed, 28 Jan 2015 08:13:46 -0600
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: parsing tree from excel sheet
In-Reply-To <cirqviF15qtU1@mid.individual.net>
References <cirqviF15qtU1@mid.individual.net>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AuthUser tim@thechases.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18220.1422455440.18130.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1422455440 news.xs4all.nl 2956 [2001:888:2000:d::a6]:46809
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84759

Show key headers only | View raw


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



Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-28 10:12 +0000
  Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-28 15:08 +0100
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-28 14:27 +0000
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-29 21:02 +0000
      Re: parsing tree from excel sheet MRAB <python@mrabarnett.plus.com> - 2015-01-29 21:16 +0000
        Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-29 21:32 +0000
          Re: parsing tree from excel sheet Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-29 21:59 +0000
          Re: parsing tree from excel sheet Chris Kaynor <ckaynor@zindagigames.com> - 2015-01-29 14:30 -0800
          Re: parsing tree from excel sheet Chris Angelico <rosuav@gmail.com> - 2015-01-30 10:46 +1100
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-30 15:05 +0000
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-30 18:11 +0100
        Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-31 22:45 +0000
          Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-02-01 11:11 +0100
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-30 18:24 +0100
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-31 10:07 +0100
      Re: parsing tree from excel sheet Peter Otten <__peter__@web.de> - 2015-01-31 10:07 +0100
  Re: parsing tree from excel sheet Tim Chase <python.list@tim.thechases.com> - 2015-01-28 08:13 -0600
    Re: parsing tree from excel sheet al.basili@gmail.com (alb) - 2015-01-29 21:22 +0000

csiph-web