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

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commons/pyRepetUnit/profilesDB/InsertProfilesMapFileInDB.py	Tue Apr 30 14:33:21 2013 -0400
@@ -0,0 +1,35 @@
+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()
\ No newline at end of file