Creating and appending csv files

156 views Asked by At

I am working on my first python project and am in over my head. I am trying to collect bike share data from an xml feed.

I want to capture this data every n minutes, lets say 5 for now, then create a csv file of that data. Additionally I want to create a second file that appends the first file so I have a historical database. The headers in the csv are: [ "id", "name", "terminalName", "lastCommWithServer", "lat", "long", "installed", "locked", "installDate", "removalDate", "temporary", "public", "nbBikes", "nbEmptyDocks", "latestUpdateTime" ] I made a start but I'm not going no where slowly! Any help would be appreciated.

This is what I have but the csv writing is a mess.

import urllib
import csv

url = 'http://www.capitalbikeshare.com/data/stations/bikeStations.xml'
connection = urllib.urlopen(url)
data = connection.read()

with open('statuslog.csv', 'wb') as myfile:
    wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
    wr.writerow(data)
0

There are 0 answers