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


Groups > comp.lang.python > #54650

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

X-Received by 10.224.93.19 with SMTP id t19mr10656515qam.3.1379956212082; Mon, 23 Sep 2013 10:10:12 -0700 (PDT)
X-Received by 10.182.80.135 with SMTP id r7mr11868obx.12.1379956212053; Mon, 23 Sep 2013 10:10:12 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!d5no1633934qap.0!news-out.google.com!gv3ni1252qab.0!nntp.google.com!d5no1633933qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Mon, 23 Sep 2013 10:10:11 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=110.159.110.249; posting-account=kGmQ2goAAACM2FcjFFzWfncmF59pQ5XI
NNTP-Posting-Host 110.159.110.249
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <fbfc360b-0553-4203-b89a-80b4c4036aec@googlegroups.com> (permalink)
Subject What's the best way to extract 2 values from a CSV file from each row systematically?
From quarantinemiles@gmail.com
Injection-Date Mon, 23 Sep 2013 17:10:12 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Xref csiph.com comp.lang.python:54650

Show key headers only | View raw


Hey guys,

I'm a little new to Python, and am still learning!

I'm test building a web scraper that extracts prices from a website, based on two values I want to extract from a CSV file. The CSV has at least 1000 rows, an example:

0,0,KGD,0,DME,0,,0,0

The values I want to extract are KGD and DME (columns 3 and 5).

Each row in the CSV file contains values in columns 3 and 5 that I'd like to extract. What's the best way to extract these data, so I can insert them as inputs in two different fields in a form? A list, dictionary, or MySQL? I try not to do anything with MySQL as I'm not familiar with it at all.

I'm thinking of dictionary because at least I can make it work as a key/value pair (for columns 3 and 5), but a dictionary is unordered. I'd like to automatically go through each row in the CSV file from beginning to end to extract the two values in columns 3 and 5 and insert them into fields in a form.

I'd really appreciate any suggestions or help, thanks in advance!


Back to comp.lang.python | Previous | NextNext 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