Mercurial > repos > yufei-luo > s_mart
view commons/pyRepetUnit/profilesDB/InsertProfilesMapFileInDB.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line source
from commons.core.coord.Map import Map from pyRepet.sql.TableAdaptator import TableMapAdaptator class InsertProfilesMapFileInDB(object): ''' Insert a map File in a database You have to specified the input file name, the table name and the repetDB object when you create the object ''' def __init__(self, inputFileName, tableName, db): ''' Constructor ''' self.inputFileName = inputFileName self.tableName = tableName self.db = db def createAndLoadTable(self): ''' Create the table and load the map data from input table ''' self.db.createTable(self.tableName, "map", overwrite = True) f = open (self.inputFileName, "r") iMap = Map() lMap = [] while iMap.read( f ): lMap.append(iMap) iMap = Map() f.close() self._tMapA = TableMapAdaptator( self.db, self.tableName ) self._tMapA.insMapList( lMap ) if __name__ == "__main__": main()