2012/1/23 Hector <hecto...@gmail.com>
> On Mon, Jan 23, 2012 at 3:01 AM, Francesc Alted <fal...@pytables.org>
> wrote:
> > 2012/1/23 Hector <hecto...@gmail.com>
> >>
> >> I guess the only reason why I'm thinking of a Table is to be able to
> >> create an index on one of its columns and then be able to do fast
> >> queries. If I could also do fast queries on a VLArray that would be
> >> great too! Is this actually possible?
> >
> >
> > Ok. What if you use a VLArray to text sentences, and a Table to store
> your
> > other variables? Then you only have to add a new column in your table
> with
> > the index (that's like a pointer) to the sentence in the VLArray to
> easily
> > retrieve it.
> >
> > --
> > Francesc Alted
>
>
>
> Thanks Francesc, but I'm not sure how to proceed. Let me give you and
> example. My data looks like these sentences (assuming a csv format):
>
> "teléfono", "Su teléfono es nuevo."
> "manzana", "La manzana está barata."
> "teléfono", "El teléfono es 123-456."
>
> the first column is a token (usually just a word, but could be a
> phrase too), and the second column is a sentence. All I need is to be
> able to select all the sentences where, for example, token equals
> "teléfono". It's a simple table, but I would need to use VLArray for
> both columns and don't really get where the pointer metaphor applies.
>
A possible venue would be to put the tokens (words) in a column of a Table
object. You can do that by using a regular StringCol(itemsize=32) (call it
'token'). There you can put all your tokens as long as they are not larger
than 32 chars (this is equivalent to a varchar(itemsize) in relational
databases, so don't worry about putting tokens smaller than 32; they will
be correctly retrieved). Then, in another column (call it 'sentence'), you
just have to put the number of the row of the sentence in the VLArray.
With this, doing a query it is only a matter of doing:
mytoken = 'telefono'
for row in table.where('token == my_token'):
my_sentence = vlarray[row['sentence']]
But, alas, the tables does not support Unicode strings, so your tokens can
only be plain ascii. Well, you can still use 8-bit ascii with a certain
codification, or just use 7-bit ascii, and then disambiguate after the
query.
Hope this helps,
--
Francesc Alted
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users