title: Reading csv file to python ValueError: could not convert string to float
body: <p>Any help with this would be appreciated. Please keep in mind that I am a beginner in Python. This is the portion of the code that I am having trouble with:</p>
  
  <pre><code>__author__ = 'peter'
  
  
  
  from datetime import datetime, timedelta
  import csv
  
  
  TICKER='CHTR'
  STDEV_FILE = TICKER + '_stdev.csv'
  TRADES_FILE = TICKER + '_trades.csv'
  DATETIME_CSV_FORMAT = '%Y%m%d %H:%M:%S'
  
  def read_data(csv_filename):
    result = {}
    with open(csv_filename, 'rb') as csvfile:
       reader = csv.reader(csvfile, delimiter=',', quotechar='|')
       header = reader.next()
       #print 'HEADER',header
       for row in reader:
          new_data=None
          if len(row)==6: # this is a QUOTES file
            ticker, date, time, price, rtn, standard = row
            rtn = float(rtn)
            standard = float(standard)
            new_data = [rtn, standard]
          else: # assume this is a TRADES file otherwise
            ticker, date, time, price, size = row
            price = float(price)
            size = int(size)
            new_data = [price, size]
  
          date_object = datetime.strptime(date +' '+time, DATETIME_CSV_FORMAT)
          if not ticker in result:
            result[ticker]=[]
          result[ticker].append([date_object] + new_data)
    return result
  
  vol = read_data(STDEV_FILE)
  trades = read_data(TRADES_FILE
  </code></pre>
  
  <p>)</p>
  
  <p>When I run it this is the error I recieve:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/peter/PycharmProjects/Vol/Vol.py", line 39, in &lt;module&gt;
      vol = read_data(STDEV_FILE)
    File "/home/peter/PycharmProjects/Vol/Vol.py", line 25, in read_data
      standard = float(standard)
  ValueError: could not convert string to float: #DIV/0!
  </code></pre>
  
  <p>I have run this on other csv files and had no trouble. </p>
  
  <p>Here is a small sample of the csv file:</p>
  
  <pre><code>SYMBOL  DATE    TIME    PRICE          RTN                     STDEV
  -----------------------------------------------------------------------
  CHTR    20130718    9:30:00 124.66  0                0
  -----------------------------------------------------------------------
  CHTR    20130718    9:30:00 124.66  0                0.0005674559
  -----------------------------------------------------------------------
  CHTR    20130718    9:30:00 124.56  -0.0008025039        0.0004539101
  -----------------------------------------------------------------------
  CHTR    20130718    9:30:00 124.54  -0.0001605781        0.0001135459
  -----------------------------------------------------------------------
  CHTR    20130718    9:30:00 124.54  0                0.0070177722
  -----------------------------------------------------------------------
  CHTR    20130718    9:31:56 123.310 -0.0099246286        0.011065531
  -----------------------------------------------------------------------
  CHTR    20130718    9:34:05 124.018 0.0057243955         0.0040363557
  -----------------------------------------------------------------------
  </code></pre>
  
  <p>Ultimately I would like to plot the standard deviation on y axis and seconds from midnight on x axis. Any help would be appreciated.</p>