Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'package,': 0.03; 'processed': 0.05; 'encode': 0.09; 'fails.': 0.09; 'modules.': 0.09; 'non-ascii': 0.09; 'through,': 0.09; 'cc:addr:python-list': 0.10; 'files.': 0.13; 'properly': 0.15; 'ascii,': 0.16; 'big,': 0.16; 'codec': 0.16; 'csv': 0.16; 'ordinal': 0.16; 'which,': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'module,': 0.17; "i'd": 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'expanding': 0.27; 'converting': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'character': 0.29; 'unlike': 0.30; 'url:python': 0.32; 'traceback': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'but': 0.36; 'url:org': 0.36; 'rather': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'john': 0.60; 'skip:u 10': 0.60; 'records': 0.68; 'soon': 0.70; '14:': 0.84; '2013': 0.84; 'packaged': 0.84; 'sender:addr:chris': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=Qm5dUzmcReJiRKKARtyDv3hYqjsrj0wHP1SCCgHbQS0=; b=LNaPLcR+SGzzELtawSnpuW1b6pioKIMrnwjZV9P/RAQe/AYxPXlSXf59QKhuEhmRg6 xSEwGbhrGFYSffoOPwyWueZaYEkTapFRZ9ulc55nym21FDCZe7Z2QCsHWaZFn+4Ketts 3wrSFnQZNWXeJBfWe4t/7fBJ5ErrtO951kqJE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=Qm5dUzmcReJiRKKARtyDv3hYqjsrj0wHP1SCCgHbQS0=; b=VtLQ+U11cNPp/Rp42edJSJbHU7Iss00SqQBP6CYc1wgrbOkFKE0s0+AuGeP0MPZq8E XjklzPeOwGPRh0s3A5+C+0ipf2J/YDaq71f6/kHZnvpjPRT8ydG2IWbTep2YgtDzYE+7 tcOUXqFsLZsbHsSKw3T+kMs9761EdhCtaxhbycwiurDIea/Zla3I0oGdS2dxdhEE8+fQ x5ILSmCxsZKBS0EOetOQWxMWshTKXnRAKLwX9mKLDRPG+OeFrO6v1Hy04zdiUg++jxN3 gi+kJt1s1iyObnSCgfDfgUNqu4/TDgkCcp7I7jSE+hY+9v2dzwM7xgzLyMs4CSNs1/Sj +Ggg== MIME-Version: 1.0 X-Received: by 10.42.42.69 with SMTP id s5mr33990861ice.2.1362639841232; Wed, 06 Mar 2013 23:04:01 -0800 (PST) Sender: chris@rebertia.com In-Reply-To: References: Date: Wed, 6 Mar 2013 23:04:00 -0800 X-Google-Sender-Auth: 3_k19kbhdxlQew8qcBA1uZBwVq4 Subject: Re: Unhelpful traceback From: Chris Rebert To: John Nagle Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQlMtLH0p2LikVAMm6UEsnBmu2j8nkTKYuaTV6TCd54+sOBh3JclMoO2TnJJddf6uZ49nMKD Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362639844 news.xs4all.nl 6878 [2001:888:2000:d::a6]:57491 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40712 On Wed, Mar 6, 2013 at 10:33 PM, John Nagle wrote: > Here's a traceback that's not helping: > UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in > position 14: ordinal not in range(128) > The program is converting some .CSV files that come packaged in .ZIP > files. The files are big, so rather than expanding them, they're > read directly from the ZIP files and processed through the ZIP > and CSV modules. > This works for data records that are pure ASCII, but as soon as some > non-ASCII character comes through, it fails. I'd recommend using the `unicodecsv` package, which, unlike the std lib `csv` module, is properly Unicode-compatible: https://pypi.python.org/pypi/unicodecsv Cheers, Chris