Remove the calls to str()
. These try to convert the unicode data you have to bytecode, using the default ASCII encoding.
You probably want to use the csv
module here and save yourself the grief of having to write all those commas, but if you cannot, at least use loops properly:
with codecs.open("extracted_osm_file.csv", "w", encoding="utf-8") as fileobj:
for line in list_way_id:
fileobj.write(u'Way ID Ref No: {}\n'.format(line[0]))
fileobj.write(u'Node reference id, latitude, longitude: \n')
fileobj.write(u'\n'.join([u','.join(subentry)
for entry in line[1:] for subentry in entry]))
which, for your partial example, would write:
Way ID Ref No: 72439830
Node reference id, latitude, longitude:
298094414,52.4626304,10.5579578
860126050,52.4626762,10.5576574
name,General-BeckStra\xc3\x9fe