[Tutor] extract uri from beautiful soup string

Sander Sweers sander.sweers at gmail.com
Mon Oct 15 01:12:17 CEST 2012


Norman Khine schreef op zo 14-10-2012 om 23:10 [+0100]:
> One thing is that when I try to write the assoc_data into a CSV file,
> it groaks on
> 
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xc7' in position 0:

It looks like python is doing an implicit decode/encode on one of your
strings. It may be caused in codecs.open. You will have to hunt down
where this implicit decode/encode is done, see
http://nedbatchelder.com/text/unipain.html for more info.

> here some sample data from the print:

These strings don't cause any errors for me and fit in ascii. Add some
print statements before your write the string to find which string is
causing you grief.

Greets
Sander

> [u'Social', u'Action9', u'ash-nimes at aol.com',
> mise en place d'ateliers, d'animations hebdomadaires et ponctuelles
> afin de lutter contre toutes les formes d'exclusion., Mme Liberté
> Bisbal, 04.66.27.24.84, 3002 Rte de Courbessac, 04.66.27.24.84, 30000
> NIMES, Madame BISBAL Liberté, 04.66.27.24.84,  ]
> [u'Social', u'Adapei30', u'contact at adapi30.org', deux lieux d'echanges
> et d'infos des publics concernes par le probleme du handicap mental
> representation aupres de divers organismes d'etat et du departement.,
> 17b, RUE CHILDEBERT, 04.66.21.21.49, 30900 NIMES, Monsieur FLUTTE
> Bernard,  ]
> [u'Sport', u'Aero-club de nimes-courbessac', u'aeroclubnimes at free.fr',
> promouvoir , de faciliter et d'organiser la pratique de l'aviation, 65
> Aerodrome de Nimes Courbessac, 04.66.28.16.00, 30000 NIMES, Monsieur
> VASSAL PATRICK,  ]
> 
> How do I change to code to take note of the latin-1 encoding?



More information about the Tutor mailing list