Ejemplo n.º 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)
 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 self.catalogue.FLOAT_ATTRIBUTE_LIST:
                 self.catalogue.data[key] = _float_check(
                     self.catalogue.data[key], 
                     row[key])
             elif key in self.catalogue.INT_ATTRIBUTE_LIST:
                 self.catalogue.data[key] = _int_check(
                     self.catalogue.data[key],
                     row[key])
             else:
                 self.catalogue.data[key].append(row[key])
     output_cat = self.export(cat_id, cat_name)
     return output_cat
class GenericCataloguetoISFParser(object):
    '''
    Reads the generic csv catalogue file to return an instance of the
    ISFCatalogue class
    '''
    def __init__(self, filename):
        '''
        '''
        self.filename = filename
        self.catalogue = None

    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 self.catalogue.FLOAT_ATTRIBUTE_LIST:
                    self.catalogue.data[key] = _float_check(
                        self.catalogue.data[key], 
                        row[key])
                elif key in self.catalogue.INT_ATTRIBUTE_LIST:
                    self.catalogue.data[key] = _int_check(
                        self.catalogue.data[key],
                        row[key])
                else:
                    self.catalogue.data[key].append(row[key])
        output_cat = self.export(cat_id, cat_name)
        return output_cat

    def export(self, cat_id=None, cat_name=None):
        """
        Exports the catalogue to ISF Format
        """
        return self.catalogue.write_to_isf_catalogue(cat_id, cat_name)
Ejemplo n.º 4
0
class GenericCataloguetoISFParser(object):
    '''
    Reads the generic csv catalogue file to return an instance of the
    ISFCatalogue class
    '''
    def __init__(self, filename):
        '''
        '''
        self.filename = filename
        self.catalogue = None

    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)

    def export(self, cat_id=None, cat_name=None):
        """
        Exports the catalogue to ISF Format
        """
        return self.catalogue.write_to_isf_catalogue()
Ejemplo n.º 5
0
 def __init__(self, filename):
     '''
     '''
     self.filename = filename
     self.catalogue = GeneralCsvCatalogue()