Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88956

Re: using DictReader() with .decode('utf-8', 'ignore')

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <vincent@vincentdavis.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; "subject:')": 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'assume': 0.14; "'r',": 0.16; 'csv': 0.16; 'module?': 0.16; 'received:209.85.216.53': 0.16; 'subject:ignore': 0.16; 'symbols': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'so.': 0.16; 'work,': 0.20; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'subject: .': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'open': 0.33; 'reader': 0.33; 'subject:with': 0.35; 'received:209.85': 0.35; 'received:google.com': 0.35; 'received:209.85.216': 0.37; 'received:209': 0.37; 'skip:p 20': 0.39
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=ok9Bv5rKiNRCElC3ynw2Pto8nY0WfFKC0FlKfBg3hEs=; b=hBPhXVvB5Cg+y+QUgfgY3C58ARHukvVsW4gwxZwmukR1Y3UXybPr3XR4Xh2n+9cI6/ tYshc8KkkqHPKd5iD8vMLrmewMVsK4AiKftZbUPgeaMXnXYftQccOYgC1LezwpW+9/xS InioOhGN9g3k5d+RFY2E3wsm6n396qWe71sSAh3Srf5Gx1591dt+82X8FMfE6TMJyAxa 7Rwp/ATA/i5GdnFFRVd01+jbyCH8xAyEbXWEY8/55Ci9j2CmN6wguyvW7bYob0+tGtb/ CTAdOlEExGl4FTotAK3udBSqwnJtome5u4xD500zF6QQqLWRIksjH83JEc2NGcGJZ6sn qXYQ==
X-Gm-Message-State ALoCoQkkh0AQnHZLEBFvm296J4hsnNcpuyaYNBDn8rWfdfLoDiWfeNl3W8ADc+mUM4XPBQVvSvJ9
X-Received by 10.60.45.244 with SMTP id q20mr8969257oem.35.1429018693913; Tue, 14 Apr 2015 06:38:13 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <552d14c0$0$12991$c3e8da3$5496439d@news.astraweb.com>
References <mailman.286.1429016466.12925.python-list@python.org> <552d14c0$0$12991$c3e8da3$5496439d@news.astraweb.com>
From Vincent Davis <vincent@vincentdavis.net>
Date Tue, 14 Apr 2015 07:37:53 -0600
Subject Re: using DictReader() with .decode('utf-8', 'ignore')
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Cc "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=001a11c220d6a0e56a0513af57bd
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.288.1429018696.12925.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1429018696 news.xs4all.nl 2921 [2001:888:2000:d::a6]:45015
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88956

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

> Which DictReader? Do you mean the one in the csv module? I will assume so.
>
​yes.​


>
> # untested
> with open(dfile, 'r', encoding='utf-8', errors='ignore', newline='') as f:
>     reader = csv.DictReader(f)
>     for row in reader:
>         print(row['fieldname'])
>

What you have seems to work, now I need to go find my strange symbols that
are not ​'utf-8' and see what happens
I was thought, that I had to open with 'rb' to use ​encoding?


Vincent Davis

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

using DictReader() with .decode('utf-8', 'ignore') Vincent Davis <vincent@vincentdavis.net> - 2015-04-14 06:54 -0600
  Re: using DictReader() with .decode('utf-8', 'ignore') Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-14 23:23 +1000
    Re: using DictReader() with .decode('utf-8', 'ignore') Vincent Davis <vincent@vincentdavis.net> - 2015-04-14 07:37 -0600
      Re: using DictReader() with .decode('utf-8', 'ignore') Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-14 23:48 +1000
        Re: using DictReader() with .decode('utf-8', 'ignore') Vincent Davis <vincent@vincentdavis.net> - 2015-04-14 08:51 -0600

csiph-web