download specific columns of csv using requests.get
<p>I am using <code>requests.get</code> to download a csv file. I only need two columns from this csv file and the rest of the column are useless for me. Currently I am using </p>

<pre><code>r = requests.get(finalurl, verify=False,stream=True)
shutil.copyfileobj(r.raw, csvfile) 
</code></pre>

<p>to get the complete csv file.</p>

<p>However, I only want to download two column from the csv file. I can always download the entire content and then take what is necessary. </p>

<p>Just checking if there is a way to get specific column using <code>requests.get</code>
Eg: <a href="http://chart.finance.yahoo.com/table.csv?s=AAPL&amp;a=7&amp;b=20&amp;c=2016&amp;d=8&amp;e=20&amp;f=2016&amp;g=d&amp;ignore=.csv" rel="nofollow">http://chart.finance.yahoo.com/table.csv?s=AAPL&amp;a=7&amp;b=20&amp;c=2016&amp;d=8&amp;e=20&amp;f=2016&amp;g=d&amp;ignore=.csv</a> </p>

<p>I need only <code>date</code> and <code>Adj.close</code> from this csv file.</p>

<p>Couldn't find similar questions, please direct me if similar question was asked earlier.</p>

<p>Thanks</p>

<p>Try <a href="http://pandas.pydata.org/" rel="nofollow">pandas</a>, in your situation, pandas is more convenient.</p>

<pre><code>In [2]: import pandas.io.data as web
   ...: aapl = web.DataReader("AAPL", 'yahoo','2016-7-20','2016-8-20')
   ...: aapl['Adj Close']
   ...:
   ...:
Out[2]:
Date
2016-07-20     99.421412
2016-07-21     98.894269
2016-07-22     98.128421
2016-07-25     96.815526
2016-07-26     96.149138
2016-07-27    102.395300
2016-07-28    103.777810
2016-07-29    103.648513
2016-08-01    105.478603
2016-08-02    103.917063
2016-08-03    105.220002
2016-08-04    105.870003
2016-08-05    107.480003
2016-08-08    108.370003
2016-08-09    108.809998
2016-08-10    108.000000
2016-08-11    107.930000
2016-08-12    108.180000
2016-08-15    109.480003
2016-08-16    109.379997
2016-08-17    109.220001
2016-08-18    109.080002
2016-08-19    109.360001
Name: Adj Close, dtype: float64
</code></pre>

python csv download python-requests