Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'column': 0.07; 'subject:file': 0.07; 'subject:skip:s 10': 0.07; 'string': 0.09; 'guys!': 0.09; 'parameter': 0.09; 'cc:addr:python-list': 0.11; '*class': 0.16; 'columns': 0.16; 'csv': 0.16; 'headers,': 0.16; 'lot!': 0.16; 'subject: \n ': 0.16; 'subject:CSV': 0.16; 'subject:values': 0.16; 'tim,': 0.16; 'module': 0.19; 'alex': 0.19; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'headers': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'array': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'file:': 0.31; 'file': 0.32; 'url:python': 0.33; 'subject:the': 0.34; 'subject:from': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; "i'll": 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'easily': 0.37; 'from:addr:googlemail.com': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'read': 0.60; 'skip:* 10': 0.61; 'provide': 0.64; 'to:addr:gmail.com': 0.65; 'br,': 0.84; 'incredibly': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=UVA04CLTf62doySNCHicDQScCvazalGiI3AmMwEzRTM=; b=kIA681yW2DoV81m094/I8N5yPUjpPOyeHssNOJAIdh+LOZH3N1ToOMf6+fLShcDQRC vShKdL4+CzTNnBSMlWia120r/i3z7TwHCPbKQxTHNpQLRxrh179gu9tkfLWKqA286bbK gCoZVsAlyxbraft0nOKuptNvRjQIEw4R/MRYyFJZjemndah+CFOQoR9S5/JM5m6Fd8h8 Eou+kZKGGR59m7L7h+0QIHDZWrkClOzcaliUUUqAwT//lBf/kmN17LvGQTcqBblVysBO VF1SRaylPevUKmTRFFXwha8JooCK4A3pdB08XJwHVMu9M/AhDsGQGeyIqQEZi+kv486W teAQ== X-Received: by 10.152.2.4 with SMTP id 4mr4852783laq.0.1380273788710; Fri, 27 Sep 2013 02:23:08 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <037629ff-64cb-4b35-b61f-54df4d4d4603@googlegroups.com> References: <037629ff-64cb-4b35-b61f-54df4d4d4603@googlegroups.com> From: Roland Mueller Date: Fri, 27 Sep 2013 12:22:48 +0300 Subject: Re: What's the best way to extract 2 values from a CSV file from each row systematically? To: Alex Lee Content-Type: multipart/alternative; boundary=089e0112c51cde73ec04e75a089c 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: 82 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380275165 news.xs4all.nl 15936 [2001:888:2000:d::a6]:49026 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54869 --089e0112c51cde73ec04e75a089c Content-Type: text/plain; charset=ISO-8859-1 Hello, 2013/9/24 Alex Lee > Thanks for the help guys! I'll definitely read up on the csv module > documentation. > > Tim, that's incredibly helpful, thanks a lot! :) My CSV file doesn't have > headers, but I'm sure I can just as easily add it in manually. > a better way to provide column headers is to use the fieldname parameter when creating the CSV reader. fieldnames is a string array that should match the number of columns in the csv file: *class *csv.DictReader(*csvfile*, *fieldnames=None*, *restkey=None*, * restval=None*, *dialect='excel'*, **args*, ***kwds*) BR, Roland -- > https://mail.python.org/mailman/listinfo/python-list > --089e0112c51cde73ec04e75a089c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello,

2013/9/24 Alex Lee <quarantinemiles@gmail.com= >
Thanks for the help guys! I'll definitely read up on t= he csv module documentation.

Tim, that's incredibly helpful, thanks a lot! :) My CSV file doesn'= t have headers, but I'm sure I can just as easily add it in manually.

a better way to provide column headers i= s to use the fieldname parameter when creating the CSV reader. fieldnames i= s a string array that should match the number of columns in the csv file:

class=A0csv.DictReader(csvf= ile,=A0= fieldnames=3DNone,=A0restkey=3DNone,=A0restval=3DNone,=A0dialect=3D'excel',=A0*args,=A0**kwds= )
=A0
BR,
Roland

--
https://mail.python.org/mailman/listinfo/python-list

--089e0112c51cde73ec04e75a089c--