Return to Snippet

Revision: 14642
at June 8, 2009 12:37 by cthulhupunk0


Initial Code
"""
                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)

Initial URL


Initial Description


Initial Title
CSV example for working with myIO

Initial Tags
csv

Initial Language
Python