Update code_df_custom.py
Browse files- code_df_custom.py +11 -0
code_df_custom.py
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
import pandas as pd
|
2 |
import traceback
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
def run_code(file, code):
|
5 |
scope = {'pd': pd}
|
6 |
if file:
|
@@ -28,3 +33,9 @@ def run_code(file, code):
|
|
28 |
else:
|
29 |
print("No file provided")
|
30 |
return pd.DataFrame(), "No file provided"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import pandas as pd
|
2 |
import traceback
|
3 |
|
4 |
+
|
5 |
+
def load_excel(file):
|
6 |
+
df = pd.read_excel(file)
|
7 |
+
return file, df
|
8 |
+
|
9 |
def run_code(file, code):
|
10 |
scope = {'pd': pd}
|
11 |
if file:
|
|
|
33 |
else:
|
34 |
print("No file provided")
|
35 |
return pd.DataFrame(), "No file provided"
|
36 |
+
|
37 |
+
|
38 |
+
def export_df(df, filename):
|
39 |
+
filename = filename.replace('.xlsx', '_coded.xlsx')
|
40 |
+
df.to_excel(filename, index=False)
|
41 |
+
return filename
|