<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'import csv and then be able to add year revenue' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'import csv and then be able to add year revenue' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 24 May 2012 00:21:51 -0700</pubDate>
    <lastBuildDate>Thu, 24 May 2012 00:21:51 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>import csv and then be able to add year revenue</title>
      <link>http://www.programmersheaven.com/mb/python/417789/417789/import-csv-and-then-be-able-to-add-year-revenue/</link>
      <description>here is my csv file&lt;br /&gt;
[quote]&lt;br /&gt;
2009|1|22|56.23&lt;br /&gt;
2009|4|12|86.24&lt;br /&gt;
2009|5|20|34.67&lt;br /&gt;
2009|6|22|12.67&lt;br /&gt;
2009|3|21|795.12&lt;br /&gt;
2008|7|4|753.43&lt;br /&gt;
2008|8|9|2345.45&lt;br /&gt;
2008|9|1|2357.23&lt;br /&gt;
2010|5|2|7552.21&lt;br /&gt;
2010|3|15|666&lt;br /&gt;
2010|4|17|2323.75&lt;br /&gt;
2010|5|19|2367.23&lt;br /&gt;
2010|6|25|6453&lt;br /&gt;
2010|2|6|1267.12&lt;br /&gt;
[/quote]&lt;br /&gt;
&lt;br /&gt;
here is my code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
import csv

print ("Enter the year you want to add up the total revenue.")


reader = csv.reader(open("/revenue.csv", "rb"))
for row in reader:
    print(row)
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
here is what i have so far...sorry i am very new to python but am really enjoying it. any help would be greatly appreciated.&lt;br /&gt;
&lt;br /&gt;
thanks&lt;br /&gt;
keith&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/417789/417789/import-csv-and-then-be-able-to-add-year-revenue/</guid>
      <pubDate>Sun, 11 Jul 2010 22:08:08 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: import csv and then be able to add year revenue</title>
      <link>http://www.programmersheaven.com/mb/python/417789/418484/re-import-csv-and-then-be-able-to-add-year-revenue/#418484</link>
      <description>You have to split the row:&lt;br /&gt;
&lt;br /&gt;
values = row.split('|')&lt;br /&gt;
&lt;br /&gt;
this create a tuple of the values:&lt;br /&gt;
&lt;br /&gt;
('2009', '1', '22', '56.23')&lt;br /&gt;
&lt;br /&gt;
You can then access the columns by&lt;br /&gt;
values[0] etc.&lt;br /&gt;
Be aware that this values are strs.&lt;br /&gt;
You need to convert them to float if you want to make a sum.&lt;br /&gt;
&lt;br /&gt;
v = float(values[3].strip())&lt;br /&gt;
&lt;br /&gt;
Here v will be 56.23&lt;br /&gt;
strip() removes whitespaces, just to be sure.&lt;br /&gt;
&lt;br /&gt;
Hope it helps:&lt;br /&gt;
Imre Horvath</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/417789/418484/re-import-csv-and-then-be-able-to-add-year-revenue/#418484</guid>
      <pubDate>Sun, 29 Aug 2010 08:34:47 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>
