Hello,
I need to parse a python dictionnary coming from a table cell
here is the dict texte = {'Mia':'Oli, c’est juste le bac,\on va pas le fêter tout l’été,\on s’détend…'}
If I use directly the dict, with texteMia = texte['Mia']
I obtain
‘Oli, c’est juste le bac,\on va pas le fêter tout l’été,\on s’détend…’
If the dict is in a table cell and I use this script:
{'Mia':'Oli, c’est juste le bac,\on va pas le fêter tout l’été,\on s’détend…'}
Traceback (most recent call last):
File "</project1/dictParse:op('/project1/dictParse').run()>", line 1
td.tdError: File "/project1/dictParse", line 3
TypeError: 'td.Cell' object is not subscriptable
Results of run operation resulted in exception.
If someone can say where is the problem, I would be very grateful!
Thanks in advance, Jacques
Hello,
Thanks, but that was tried with this result
{'Mia':'Oli, c’est juste le bac,\on va pas le fêter tout l’été,\on s’détend…'}
Traceback (most recent call last):
File "</project1/dictParse:op('/project1/dictParse').run()>", line 1
td.tdError: File "/project1/dictParse", line 3
TypeError: string indices must be integers
Results of run operation resulted in exception.
hello,
here is the .toe and the .tsv database sqlite.zip (84.5 KB)
The final goal of the script is to parse each key (as ‘Mia’) in each line of remote iPhone
Thank you,
Jacques
Well, in a table you always have strings. It may look like a dict, but it’s a string. hence you get the string indices error when you try to access it like a dict
So you could store your dicts as json strings inside DATs, and then grab it into your script , do a json.loads() to convert it to a dict …