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


Groups > comp.lang.python > #54869

Re: What's the best way to extract 2 values from a CSV file from each row systematically?

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 <roland.em0001@googlemail.com>
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&gt;': 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 <fbfc360b-0553-4203-b89a-80b4c4036aec@googlegroups.com> <mailman.276.1379958332.18130.python-list@python.org> <037629ff-64cb-4b35-b61f-54df4d4d4603@googlegroups.com>
From Roland Mueller <roland.em0001@googlemail.com>
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 <quarantinemiles@gmail.com>
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 <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.374.1380275165.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Hello,

2013/9/24 Alex Lee <quarantinemiles@gmail.com>

> 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
>

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


Thread

What's the best way to extract 2 values from a CSV file from each row systematically? quarantinemiles@gmail.com - 2013-09-23 10:10 -0700
  Re: What's the best way to extract 2 values from a CSV file from each row systematically? Neil Cerutti <neilc@norwich.edu> - 2013-09-23 17:20 +0000
  Re: What's the best way to extract 2 values from a CSV file from each row systematically? Joel Goldstick <joel.goldstick@gmail.com> - 2013-09-23 13:25 -0400
  Re: What's the best way to extract 2 values from a CSV file from each row systematically? Tim Chase <python.list@tim.thechases.com> - 2013-09-23 12:47 -0500
    Re: What's the best way to extract 2 values from a CSV file from each row systematically? Alex Lee <quarantinemiles@gmail.com> - 2013-09-24 07:04 -0700
      Re: What's the best way to extract 2 values from a CSV file from each row systematically? Roland Mueller <roland.em0001@googlemail.com> - 2013-09-27 12:22 +0300
  Re: What's the best way to extract 2 values from a CSV file from each row systematically? Luca Cerone <luca.cerone@gmail.com> - 2013-09-28 03:21 -0700

csiph-web