What is the best data structure for a very simple spreadsheet?

vsoler vicente.soler at gmail.com
Sun Jan 3 06:27:46 EST 2010


Hi,

Not sure this is the best group to post, but I cannot think of any
other.

My application would contain a limited set of "cells" represented by
the instances of a Cell class:

class Cell:
...

A1=Cell(7)
A2=Cell(2*A1)
A3=Cell(3*A1+A2)
A4=Cell(A3*4)

Of course, A1 = 7, A2 = 14, A3 = 35 and A4 = 140

Now, I somehow want to be able to show a dependency tree

1 level dependency trees
  A1: None
  A2: A1
  A3: A1, A2
  A4: A3

All levels dependency trees

  A1: None
  A2: A1
  A3: A1, A2
  A4: A3, A2, A1

Leaf + values dependency trees:

  A1: 7
  A2: A1=7, 2
  A3: 3, A1=7, 2
  A4: 3, A1=7, 2, 4

What I'd like to know is:

1) what are, in your opinion, the basic elements of the Cell class?
2) Do I need a parser to evaluate the formulas like “3*A1+A2”? Can you
recommend one library that already contains one?
3) Do I need a tree data structure to represent my data? would the
tree be an attribute of the class instance?

I imagine a lot can be said on these questions. What I am looking for
is some hints that help me get out of where I am now.

Any help is highly appreciated.

Vicente Soler



More information about the Python-list mailing list