title: Writing Values From Python into Excel
body: <p>What I am trying to do is to get this line of code to work by putting a price from Yahoo Finance for a stock into a spreadsheet. I have asked quite a few people and I have researched the issue but I haven't gotten it to work.</p>
  
  <p>This is the trouble line of code:</p>
  
  <pre><code>ws.cell(1,i+1).value = str.replace(price','price')
  </code></pre>
  
  <p>I get errors likes, "replace' requires a 'str' object but received a 'list' or 'int' object has no attributes everytime I modify it. Thanks for the help in advance.</p>
  
  <pre><code>from openpyxl import Workbook
  
  import urllib
  import re
  
  from openpyxl.cell import get_column_letter
  
  wb = Workbook()
  
  dest_filename = r'empty_book.xlsx'
  
  ws = wb.create_sheet()
  
  ws.title = 'Stocks'
  symbolslist = ["aapl","spy","goog","nflx"] 
  
  i=0
  while i&lt;len(symbolslist):
      #counts each object as 1 in the list
      url = "http://finance.yahoo.com/q?s="+symbolslist[i]+"&amp;q1=1"
      htmlfile = urllib.urlopen(url)
      htmltext = htmlfile.read()
      regex = '&lt;span id="yfs_l84_'+symbolslist[i]+'"&gt;(.+?)&lt;/span&gt;'
      pattern = re.compile(regex)
      price = re.findall(pattern,htmltext)
      print "The price of", symbolslist[i], " is ", price 
      ws.cell(1,i+1).value = str.replace(price','price')
      i+=1
  
  
  wb.save(filename = dest_filename)
  </code></pre>
  
  <p>Importing the CSV module is better than using Excel for data analysis because it is open source friendly.</p>