Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,4 +1,15 @@
|
|
| 1 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def safe_dataframe(data, key):
|
| 4 |
"""Safely convert extracted data to a pandas DataFrame"""
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
def measure_time(func): #already decorated the read_file()
|
| 5 |
+
"""Decorator for measuring time taken during the OCR"""
|
| 6 |
+
def wrapper(*args, **kwargs):
|
| 7 |
+
start = time.time()
|
| 8 |
+
result = func(*args, **kwargs)
|
| 9 |
+
end = time.time()
|
| 10 |
+
print(f"Execution time: {end - start:.6f} seconds")
|
| 11 |
+
return result
|
| 12 |
+
return wrapper
|
| 13 |
|
| 14 |
def safe_dataframe(data, key):
|
| 15 |
"""Safely convert extracted data to a pandas DataFrame"""
|