comparison commons/pyRepetUnit/profilesDB/InsertProfilesMapFileInDB.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
comparison
equal deleted inserted replaced
30:5677346472b5 31:0ab839023fe4
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()