Some tweaks for importing data from Excel (xlsx) files
specifically some member patronage numbers for fiscal year
This commit is contained in:
		
							parent
							
								
									25e30fd378
								
							
						
					
					
						commit
						6c89ca95f9
					
				
					 2 changed files with 13 additions and 3 deletions
				
			
		|  | @ -2,7 +2,7 @@ | |||
| ################################################################################ | ||||
| # | ||||
| #  Rattail -- Retail Software Framework | ||||
| #  Copyright © 2010-2020 Lance Edgar | ||||
| #  Copyright © 2010-2022 Lance Edgar | ||||
| # | ||||
| #  This file is part of Rattail. | ||||
| # | ||||
|  | @ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import | |||
| import os | ||||
| 
 | ||||
| from rattail import importing | ||||
| from rattail.excel import ExcelReader | ||||
| from rattail.excel import ExcelReaderXLS, ExcelReaderXLSX | ||||
| 
 | ||||
| 
 | ||||
| class FromFile(importing.Importer): | ||||
|  | @ -68,7 +68,10 @@ class FromExcelFile(FromFile): | |||
|         return '{}.xlsx'.format(self.model_name) | ||||
| 
 | ||||
|     def open_input_file(self): | ||||
|         self.excel_reader = ExcelReader(self.input_file_path) | ||||
|         if self.input_file_path.endswith('.xls'): | ||||
|             self.excel_reader = ExcelReaderXLS(self.input_file_path) | ||||
|         else: | ||||
|             self.excel_reader = ExcelReaderXLSX(self.input_file_path) | ||||
| 
 | ||||
|     def close_input_file(self): | ||||
|         pass | ||||
|  |  | |||
|  | @ -229,6 +229,13 @@ class Importer(object): | |||
|             end_time = datetime.datetime.combine(end_date, datetime.time(0)) | ||||
|             self.end_time = self.app.localtime(end_time) | ||||
| 
 | ||||
|         # and some commands use --year instead of date range | ||||
|         if not hasattr(self, 'year') or not self.year: | ||||
|             if hasattr(self, 'args') and hasattr(self.args, 'year'): | ||||
|                 self.year = self.args.year | ||||
|             else: | ||||
|                 self.year = None | ||||
| 
 | ||||
|     def setup(self): | ||||
|         """ | ||||
|         Perform any setup necessary, e.g. cache lookups for existing data. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar