jeudi 2 avril 2015

dealing with variable length arrays in sqlite

I have some code that generates a SQLite DB, whcih I then need to analyze. Each row represents an event, and each event has several entries which are themselves 1D arrays.


for eg



event StateResTime CurrentStep
1 [1,2,3] [4,5,6]
2 [2,5] [1,4]
...


I want to query the DB to get a 2D array with variable length rows (is such a thing possible?) in python.


if I simply use the query:



q = "select StateResTime from metadata..."


I get a 1D array with all the elements simply concatenated together ([1,2,3,2,5] in the example above - in theory I could work with this and process it like that, but it's a horribly unintuitive way to do things. Is it possible to get a nicer array structure out of the DB and into python, something like [[1,2,3],[2,5]], so that array[0] would give me the StateResTime array for event 0?


Aucun commentaire:

Enregistrer un commentaire