insert a list 2xn obtained from a json in python -


hi i'm trying access json save in list perform sort of append , create pdf in reportlab, have following code have several problems first have list of 2xn has columns , rows dynamic according json. if can me grateful much

import json  json_data = [] attributesname = [] testtable = { "attributes":[] } attributesvalue = [] path="prueba2.pdf" doc = simpledoctemplate(path, pagesize=letter) stylesheet = getsamplestylesheet() text = [] open("prueba.json") json_file: document = json.load(json_file) item in document:     data_item in item['data']:         attributesname.append([str(data_item['name'])         attributesvalue.append([data_item['value']])         testtable[attributesname].extend({data_item['name'], data_item['value']}) print attributesname[0] print testtable[0]            parts = [] p = paragraph('''<para align=left fontsize=9>{0}</para>'''.format(text), stylesheet["bodytext"]) parts.append(p) doc.build(parts) 

i implemented following,but prints list

[[['rfc', 'nombre', 'apellido paterno', 'apellido materno', 'fecha nacimiento', 'calle', 'no. exteri or', 'no. interior', 'c.p.', 'entidad', 'municipio', 'colonia',    'documento']], [['morr910304fl2', 'r jose', 'montiel', 'robles', '1992-02-04', 'amor', '4', '2', '55064', 'edo de   mex', 'ecatepec', 'industrial', 'documento']]] 

i want this

[['rfc'], ['22232446']] [['nombre'], ['22239952']] [['apellido'], ['22245430']] 

if change code next code

 open("prueba.json") json_file:     document = json.load(json_file)     item in document:        data_item in item['data']:          attributesname.append(str(data_item["name"]))          attributesvalue.append(str(data_item["value"]))          tabla.append([[attributesname],[attributesvalue]])     print attributesname     print attributesvalue  y in tabla:     print(y) 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -