title: NOAA data and writing a csv file
body: <p>I am trying to create a csv file from NOAA data from their <a href="http://www.srh.noaa.gov/data/obhistory/PAFA.html" rel="nofollow">http://www.srh.noaa.gov/data/obhistory/PAFA.html</a>.</p>
  
  <p>At the moment, I am having problems writing the csv file.</p>
  
  <pre><code>import urllib2 as urllib
  from bs4 import BeautifulSoup
  from time import localtime, strftime
  import csv
  url = 'http://www.srh.noaa.gov/data/obhistory/PAFA.html'
  file_pointer = urllib.urlopen(url)
  soup = BeautifulSoup(file_pointer)
  
  table = soup('table')[3]
  table_rows = table.findAll('tr')
  row_count = 0
  for table_row in table_rows:
  row_count += 1
  if row_count &lt; 4:
   continue
  
  date = table_row('td')[0].contents[0]
  time = table_row('td')[1].contents[0]
  wind = table_row('td')[2].contents[0]
  
  print date, time, wind
  with open("/home/eyalak/Documents/weather/weather.csv", "wb") as f:
  writer = csv.writer(f)
  print date, time, wind
  writer.writerow( ('Title 1', 'Title 2', 'Title 3') )
  writer.writerow(str(time)+str(wind)+str(date)+'\n')
   if row_count == 74:
    print "74"
  </code></pre>
  
  <p>The printed result is fine, it is the file that is not. I get:</p>
  
  <pre><code>Title   1,Title 2,Title 3
  0,5,:,5,3,C,a,l,m,0,8,"
  </code></pre>
  
  <p>The problems in the csv file created are: 1. The title is broken into the wrong columns;column 2, has "1,Title" versus "title 2" 2. The data is comma delineated in the wrong places 3. As The script writes new lines it over writes on the previous one, instead of appending from the bottom. Any thoughts?</p>