diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commons/pyRepetUnit/profilesDB/InsertProfilesMapFileInDB.py	Mon Apr 29 03:20:15 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