Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/profilesDB/InsertProfilesMapFileInDB.py @ 18:94ab73e8a190
Uploaded
| author | m-zytnicki |
|---|---|
| date | Mon, 29 Apr 2013 03:20:15 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 17:b0e8584489e6 | 18:94ab73e8a190 |
|---|---|
| 1 from commons.core.coord.Map import Map | |
| 2 from pyRepet.sql.TableAdaptator import TableMapAdaptator | |
| 3 | |
| 4 class InsertProfilesMapFileInDB(object): | |
| 5 ''' | |
| 6 Insert a map File in a database | |
| 7 You have to specified the input file name, the table name and the repetDB object when you create the object | |
| 8 ''' | |
| 9 | |
| 10 def __init__(self, inputFileName, tableName, db): | |
| 11 ''' | |
| 12 Constructor | |
| 13 ''' | |
| 14 self.inputFileName = inputFileName | |
| 15 self.tableName = tableName | |
| 16 self.db = db | |
| 17 | |
| 18 def createAndLoadTable(self): | |
| 19 ''' | |
| 20 Create the table and load the map data from input table | |
| 21 ''' | |
| 22 self.db.createTable(self.tableName, "map", overwrite = True) | |
| 23 f = open (self.inputFileName, "r") | |
| 24 iMap = Map() | |
| 25 lMap = [] | |
| 26 while iMap.read( f ): | |
| 27 lMap.append(iMap) | |
| 28 iMap = Map() | |
| 29 f.close() | |
| 30 self._tMapA = TableMapAdaptator( self.db, self.tableName ) | |
| 31 self._tMapA.insMapList( lMap ) | |
| 32 | |
| 33 | |
| 34 if __name__ == "__main__": | |
| 35 main() |
