tablib icon indicating copy to clipboard operation
tablib copied to clipboard

Export data to the excel, the data is missing, there are a lot of empty lines and empty cells

Open fanjindong opened this issue 7 years ago • 1 comments

Part of the code:

data=tablib.Dataset(headers=['userId','userPhone', 'phone', 'address'])
for item in resp_data:
    order_id,user,phone,address=item.get('id',''),item.get('userPhone',''),item.get('phone',''),item.get('contact',{}).get('address')
    print('>>>',database,user,phone,address)
    if not address:
        continue
    data.append([order_id,user,phone,address])
with open('data_6.9-8.23.xls', 'wb') as f:
    f.write(data.xls)

Part of the print:

...
>>> order_waimai 152570300** 152570300** 明桂苑新风路与环站北路交叉口1幢1单元1203
>>> order_waimai 134170076** 134170076** 明昇幼儿园对面东北饺子旁边电梯上去211
>>> order_waimai 188837906** 135325400** 东莞市凯格精密机械有限公司广东省东莞市东城科技园沙朗路2号
>>> order_waimai 151593111** 151593111** 富江宾馆赛歧镇罗江开发区三江二路49号蔚蓝音乐会所2楼超市
>>> order_waimai 159900353** 159900353** 西堤北路浙江省杭州市富阳区11幢东单元201室
>>> order_waimai 132161789** 132161789** 滨兴西苑杭州市滨江区滨兴路1796号15幢1单元501室
>>> order_waimai 187546966** 187546966** 祥河小区-13号东营市东营区鱼台路58号2单元1003
>>> order_waimai 139953449** 139953449** 恒大名都通达南街与双渠口路交会处向西500米17号楼1单元1504
>>> order_waimai 138013569** 187100085** 恒通国际创新园北京市朝阳区酒仙桥北路9号C17
>>> order_waimai 134170076** 134170076** 明昇幼儿园对面东北饺子旁边电梯上去211
>>> order_waimai 158518085** 158518085** 格调海洋主题宾馆(颍上北路店)阜阳颍泉区颍上北路阜阳商厦向南200米
...

Part of the excel: tablib summarize: I am sure that have carefully checked the print data, no empty data lines, and empty data,bug export data to the excel, there are a lot of empty lines and empty cells. Finally, I had to use openpyxl to solve the problem.

fanjindong avatar Aug 25 '17 01:08 fanjindong

Could this be a duplicate of https://github.com/jazzband/tablib/issues/197? If so, strings should be used instead of big integers.

Finally, I had to use openpyxl to solve the problem.

This would suggest not, but depends how it was used.

hugovk avatar Oct 22 '19 15:10 hugovk