AnsweredAssumed Answered

Unicode Error Printing Reportlab PDF Only While Running Not Debugging

Question asked by ShreyaCh on Nov 11, 2014
Latest reply on Apr 13, 2015 by drewdowling

I have JSON data which I am formatting into two tables and printing on PDF using reportlab.

It works fine when the '&' character is not in the data else it gives The following error: 'ascii' codec can't decode byte 0xa0 in position 0: ordinal not in range(128)

The weird thing is, the code works perfectly fine while debugging the tool. The error only pops up while running the code here:, onFirstPage=on_first_page, onLaterPages=on_later_pages, canvasmaker=NumberedCanvas)

I have referred to the related questions posted. I have also tried the solution provided here and also normalizing the data. Nothing is working. It throws the same ascii error.

Here's the JSON input:

{u'Neighborhood Information': [u'Dominant Tapestry Segment:63', u'Labor Force Participation Rate:5,873', u'Total Population:17,045', u'Total Households:2,044', u'Average Household Size:3', u'Average Household Income:$58,312', u'Median Household Income:$26,260', u'Per Capita Income:$18,204', u'Total Housing Units:2,687', u'Owner Occupied HUs:400', u'Renter Occupied HUs:1,644', u'Vacant Housing Units:578', u'Median Home Value:$402,778', u'Average Home Value:$428,563'], u'Property Information': [u'Name:Rossborough Drive & Paint Branch Parkway', u'Address:Rossborough Drive & Paint Branch Parkway', u'City:College Park', u'State:MD', u'Zipcode:20742', u'Type:Commercial', u'Area (sqft):100000']}

Here's how I am building my attribute table dictionary:

TEMPDICT = {key : ATTRIBUTEDATA.find(key)} TABLEKEYSINDEX.update(TEMPDICT) SORTEDTABLESINDEX = sorted((value, key) for (key, value) in TABLEKEYSINDEX.items())

Here's how I am formatting the table:

table_key = (Paragraph(unicode((table_data[k][i].split(":"))[0], errors='ignore'), styles_table['TblBody']))  
if k == sorted_table_headers[0]: 
     if len((table_data[k][i].split(":"))[1]) != 0:
= (Paragraph(unicode((table_data[k][i].split(":"))[1], errors='ignore'), styles_table['TblBody'])) 
     if len((table_data[k][i].split(":"))[1]) !=0: 
= (Paragraph(unicode((table_data[k][i].split(":"))[1], errors='ignore'), styles_table_right['TblBo                   dy']))

I have the following versions installed on my machine:

matplotlib (1.3.0) 
Pillow (2.5.2)
ArcMap 10.2.1

Any help pointing me to the right direction would really be appreciated.