/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
""" Name : CSV.py Author : Jason Spadaro Description : Module to create comma seperated value objects Copyright 2009 """ from MyIO import * import csv class CSV(myIO): """ **************************************************** *Description : Makes comma seperated values file connections **************************************************** """ def make_connect(self): """ **************************************************** *Description : Opens the comma seperated values file **************************************************** """ self.file_name = self.connectDict["file_name"] csv_reader = csv.reader(open(self.file_name)) for row in csv_reader: self.data_rows.append(row) self.csv_writer = csv.writer(open(self.file_name), "w") def write_item(self, item): """ **************************************************** *Description : Writes to the comma seperated values file **************************************************** """" temp_list = [] for name, valitem in item.iteritems(): temp_list.append(item[name]) self.csv_writer.writerow(temp_list)