Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,9 @@ import numpy as np
|
|
4 |
from sepa import parser
|
5 |
import re
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
##################################################################
|
11 |
|
12 |
def full_function(xml_file):
|
13 |
|
@@ -96,11 +95,22 @@ def full_function(xml_file):
|
|
96 |
|
97 |
return df_entries, df_entries_example
|
98 |
|
|
|
|
|
|
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
|
105 |
|
106 |
def export_csv(xml_file):
|
@@ -109,13 +119,18 @@ def export_csv(xml_file):
|
|
109 |
|
110 |
df_entries.to_csv("./output.csv")
|
111 |
|
112 |
-
out = gr.File
|
|
|
|
|
|
|
113 |
|
114 |
-
return out, df_entries_example
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
##################################################################
|
117 |
-
##################################################################
|
118 |
-
##################################################################
|
119 |
|
120 |
desc = "Upload XML file, convert to .csv file, and analyze transactions"
|
121 |
|
@@ -129,10 +144,14 @@ with gr.Blocks() as demo:
|
|
129 |
with gr.Row():
|
130 |
#export_button = gr.Button("Export")
|
131 |
out = gr.File(label = "Output file", interactive=False, visible=False)
|
|
|
|
|
|
|
|
|
132 |
|
133 |
|
134 |
#submit_btn = gr.Button("Run analysis on XML file")
|
135 |
#export_button.click(export_csv, df_entries, csv)
|
136 |
|
137 |
|
138 |
-
gr.Interface(fn=export_csv, inputs=xml_file, outputs=[out, df_entries_example], title=desc).launch(share=True, debug =True)
|
|
|
4 |
from sepa import parser
|
5 |
import re
|
6 |
|
7 |
+
#####################################################################################################################################
|
8 |
+
#####################################################################################################################################
|
9 |
+
#####################################################################################################################################
|
|
|
10 |
|
11 |
def full_function(xml_file):
|
12 |
|
|
|
95 |
|
96 |
return df_entries, df_entries_example
|
97 |
|
98 |
+
#####################################################################################################################################
|
99 |
+
#####################################################################################################################################
|
100 |
+
#####################################################################################################################################
|
101 |
|
102 |
+
def function_code_count(df_entries):
|
103 |
+
|
104 |
+
#count number of values
|
105 |
+
df_proprietary_code_count = df_entries['proprietary_code'].value_counts()#.to_frame()
|
106 |
+
df_proprietary_code_count = pd.DataFrame(df_proprietary_code_count).reset_index(names="code")
|
107 |
+
df_proprietary_code_count.rename(columns={"proprietary_code": "count"}, inplace=True)
|
108 |
+
|
109 |
+
return df_proprietary_code_count
|
110 |
|
111 |
+
#####################################################################################################################################
|
112 |
+
#####################################################################################################################################
|
113 |
+
#####################################################################################################################################
|
114 |
|
115 |
|
116 |
def export_csv(xml_file):
|
|
|
119 |
|
120 |
df_entries.to_csv("./output.csv")
|
121 |
|
122 |
+
out = gr.File(value="output.csv", visible=True)
|
123 |
+
|
124 |
+
#count codes
|
125 |
+
df_proprietary_code_count = function_code_count(df_entries)
|
126 |
|
127 |
+
return out, df_entries_example, df_proprietary_code_count
|
128 |
+
|
129 |
+
#####################################################################################################################################
|
130 |
+
#####################################################################################################################################
|
131 |
+
#####################################################################################################################################
|
132 |
+
|
133 |
|
|
|
|
|
|
|
134 |
|
135 |
desc = "Upload XML file, convert to .csv file, and analyze transactions"
|
136 |
|
|
|
144 |
with gr.Row():
|
145 |
#export_button = gr.Button("Export")
|
146 |
out = gr.File(label = "Output file", interactive=False, visible=False)
|
147 |
+
|
148 |
+
with gr.Row():
|
149 |
+
|
150 |
+
df_proprietary_code_count = gr.DataFrame(label="Number of transactions per code")
|
151 |
|
152 |
|
153 |
#submit_btn = gr.Button("Run analysis on XML file")
|
154 |
#export_button.click(export_csv, df_entries, csv)
|
155 |
|
156 |
|
157 |
+
gr.Interface(fn=export_csv, inputs=xml_file, outputs=[out, df_entries_example, df_proprietary_code_count], title=desc).launch(share=True, debug =True)
|