def render_sheet_to_stream(self, file_stream, sheet, init=None, mapdict=None, **keywords): headers = common.get_sheet_headers(sheet) importer = sql.SQLTableImporter(file_stream[0]) adapter = sql.SQLTableImportAdapter(file_stream[1]) adapter.column_names = headers adapter.row_initializer = init adapter.column_name_mapping_dict = mapdict importer.append(adapter) save_data(importer, {adapter.get_name(): sheet.get_internal_array()}, file_type=self._file_type, **keywords)
def render_sheet_to_stream(self, model, sheet, init=None, mapdict=None, **keywords): headers = common.get_sheet_headers(sheet) importer = django.DjangoModelImporter() adapter = django.DjangoModelImportAdapter(model) adapter.column_names = headers adapter.column_name_mapping_dict = mapdict adapter.row_initializer = init importer.append(adapter) save_data(importer, {adapter.get_name(): sheet.get_internal_array()}, file_type=self._file_type, **keywords)
def test_get_sheet_headers(): data = iter([['a', 'b', 'c'], [1, 2, 3]]) sheet_stream = SheetStream('test', data) colnames_array = get_sheet_headers(sheet_stream) eq_(colnames_array, ['a', 'b', 'c'])
def test_get_sheet_headers(): data = iter([["a", "b", "c"], [1, 2, 3]]) sheet_stream = SheetStream("test", data) colnames_array = get_sheet_headers(sheet_stream) eq_(colnames_array, ["a", "b", "c"])