예제 #1
0
 def parse(self, cat_id, cat_name):
     '''
     Opens the raw file parses the catalogue then exports
     '''
     filedata = open(self.filename, 'rU')
     self.catalogue = GeneralCsvCatalogue()
     # Reading the data file
     data = csv.DictReader(filedata)
     # Parsing the data content
     for irow, row in enumerate(data):
         if irow == 0:
             valid_key_list = _header_check(row.keys(), 
                 self.catalogue.TOTAL_ATTRIBUTE_LIST)
         for key in valid_key_list:
             if key in catalogue.FLOAT_ATTRIBUTE_LIST:
                 self.catalogue.data[key] = _float_check(
                     self.catalogue.data[key], 
                     row[key])
             elif key in catalogue.INT_ATTRIBUTE_LIST:
                 self.catalogue.data[key] = _int_check(
                     self.catalogue.data[key],
                     row[key])
             else:
                 self.catalogue.data[key].append(row[key])
     self.export(cat_id, cat_name)
예제 #2
0
 def __init__(self, filename):
     '''
     '''
     self.filename = filename
     self.catalogue = GeneralCsvCatalogue()