<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 23, 2013 at 1:10 PM, <span dir="ltr"><<a href="mailto:quarantinemiles@gmail.com" target="_blank">quarantinemiles@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hey guys,<br>
<br>
I'm a little new to Python, and am still learning!<br>
<br>
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:<br>
<br>
0,0,KGD,0,DME,0,,0,0<br>
<br>
The values I want to extract are KGD and DME (columns 3 and 5).<br>
<br>
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.<br>
<br>
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.<br>
<br>
I'd really appreciate any suggestions or help, thanks in advance!<br>
<span class=""><font color="#888888"><br>
<br>
<br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">You should check out the csv module here: <a href="http://docs.python.org/2/library/csv.html#module-csv">http://docs.python.org/2/library/csv.html#module-csv</a><br>
</div><div class="gmail_extra">It will read your csv file into a list (the file rows) of lists (the columns). You can easily loop over the data to extract the columns you want using list indexing<br clear="all"></div><div class="gmail_extra">
<br>-- <br><div dir="ltr"><div>Joel Goldstick<br></div><a href="http://joelgoldstick.com" target="_blank">http://joelgoldstick.com</a><br></div>
</div></div>