|
@@ -4,7 +4,7 @@ import sqlite3
|
|
|
import pandas as pd
|
|
|
import time
|
|
|
|
|
|
-from decoding.decoding import getVettSpec, db_results_decode_pandas, db_results_decode, db_results_decode_nodict, db_encode
|
|
|
+from decoding.decoding import getVettSpec, db_results_decode_pandas, db_results_decode, db_results_decode_nodict, db_encode, isColumnToDecode
|
|
|
|
|
|
|
|
|
|
|
@@ -170,3 +170,83 @@ cond2 = ((listatesti['mappa'] - listatesti[f'mappa_{cod}']) != 0) & ((listatesti
|
|
|
|
|
|
listatesti = listatesti[cond1 & cond2]
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+vettSpec
|
|
|
+
|
|
|
+print('The first one:', chr(int(vettSpec[0]['unicode'], 16)) )
|
|
|
+print('... is a newline')
|
|
|
+
|
|
|
+for index, entry in enumerate(vettSpec):
|
|
|
+ try:
|
|
|
+ print(index+1, chr(int(entry['intcode'])), chr(int(entry['unicode'], 16)))
|
|
|
+ except Exception as err:
|
|
|
+ print(index+1, err)
|
|
|
+ if(index>0):
|
|
|
+ break
|
|
|
+
|
|
|
+print('Total:', len(vettSpec))
|
|
|
+
|
|
|
+
|
|
|
+timestamp0 = time.time()
|
|
|
+vettDictDec = {}
|
|
|
+vettDictEnc = {}
|
|
|
+for index, entry in enumerate(vettSpec):
|
|
|
+ try:
|
|
|
+ vettDictDec[chr(int(entry['intcode']))] = chr(int(entry['unicode'], 16))
|
|
|
+ vettDictEnc[chr(int(entry['unicode'], 16))] = chr(int(entry['intcode']))
|
|
|
+ except Exception as err:
|
|
|
+ print(index+1, err)
|
|
|
+ if(index>0):
|
|
|
+ break
|
|
|
+
|
|
|
+timestamp1 = time.time()
|
|
|
+print(timestamp1 - timestamp0)
|
|
|
+
|
|
|
+timestamp0 = time.time()
|
|
|
+str0 = 'c%'
|
|
|
+strEnc0 = db_encode(vettSpec, str0)
|
|
|
+
|
|
|
+queryString0 = firstQueryL(strEnc0)
|
|
|
+
|
|
|
+with sqlite3.connect(f"file:{dbFile}?mode=ro", uri=True) as connection:
|
|
|
+ connection.row_factory = dict_factory
|
|
|
+ queryReponse = connection.cursor().execute(queryString0)
|
|
|
+ lemsNoPandas0 = queryReponse.fetchall()
|
|
|
+db_results_decode(lemsNoPandas0, vettSpec)
|
|
|
+
|
|
|
+timestamp1 = time.time()
|
|
|
+print(timestamp1 - timestamp0)
|
|
|
+
|
|
|
+def db_decodeB(string):
|
|
|
+ return ''.join([vettDictDec[char] for char in string])
|
|
|
+
|
|
|
+def db_results_decodeB(result):
|
|
|
+ keysToTest = [key for key in result[0].keys() if isColumnToDecode(key)]
|
|
|
+ for row in result:
|
|
|
+ for key in keysToTest:
|
|
|
+ row[key] = db_decodeB(row[key])
|
|
|
+ return result
|
|
|
+
|
|
|
+lemsNoPandas0[0:1]
|
|
|
+db_results_decodeB(lemsNoPandas0[0:1])
|
|
|
+lemsNoPandas0[0:1]
|
|
|
+
|
|
|
+
|
|
|
+timestamp0 = time.time()
|
|
|
+str0 = 'c%'
|
|
|
+strEnc0 = db_encode(vettSpec, str0)
|
|
|
+
|
|
|
+queryString0 = firstQueryL(strEnc0)
|
|
|
+
|
|
|
+with sqlite3.connect(f"file:{dbFile}?mode=ro", uri=True) as connection:
|
|
|
+ connection.row_factory = dict_factory
|
|
|
+ queryReponse = connection.cursor().execute(queryString0)
|
|
|
+ lemsNoPandas0 = queryReponse.fetchall()
|
|
|
+
|
|
|
+db_results_decodeB(lemsNoPandas0)
|
|
|
+
|
|
|
+timestamp1 = time.time()
|
|
|
+print(timestamp1 - timestamp0)
|
|
|
+
|
|
|
+
|