Exemplo n.º 1
0
    def import_csv(self, data_source=''):
        """
        Imports objects from csv file.

        """

        if data_source == '':
            # data_source = settings.RESOURCE_GRAPH_LOCATIONS
            print '*' * 80
            print 'No data source indicated. Please rerun command with \'-s\' parameter.'
            print '*' * 80

        if isinstance(data_source, basestring):
            data_source = [data_source]

        for path in data_source:
            if os.path.isfile(os.path.join(path)):
                CSVFileImporter(path).import_all()
            else:
                file_paths = [
                    file_path for file_path in os.listdir(path)
                    if file_path.endswith('.csv')
                ]
                for file_path in file_paths:
                    CSVFileImporter(os.path.join(path, file_path)).import_all()
Exemplo n.º 2
0
 def test_n_1(self):
     og_tile_count = TileModel.objects.count()
     CSVFileImporter('tests/fixtures/data/csv/cardinality_test_data/n-1.csv'
                     ).import_all()
     new_tile_count = TileModel.objects.count()
     tile_difference = new_tile_count - og_tile_count
     self.assertEqual(tile_difference, 4)