leavoigt commited on
Commit
a576faa
·
1 Parent(s): a6dabb1

add preprocessing function

Browse files
app.py CHANGED
@@ -13,6 +13,11 @@ with gr.Blocks() as ui:
13
  with gr.Column():
14
  output = gr.Text()
15
 
 
 
 
 
 
16
  submit_btn.click(get_statistics,
17
  file_input, output)
18
 
 
13
  with gr.Column():
14
  output = gr.Text()
15
 
16
+ # Second row for additional outputs
17
+ #with gr.Row():
18
+ # statistics_output = gr.Dataframe(label="Statistics Summary")
19
+
20
+ # Submit button action
21
  submit_btn.click(get_statistics,
22
  file_input, output)
23
 
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  gradio==4.44.1
2
  pydantic==2.10.6
3
- returns>=0.26.0
 
 
1
  gradio==4.44.1
2
  pydantic==2.10.6
3
+ returns>=0.26.0
4
+ openpyxl
utils/main_processor.py CHANGED
@@ -1,11 +1,11 @@
1
  import json
2
  import os
3
  from utils.whisp_api_client import whisp_request
 
4
 
5
  # Import secrets
6
  whisp_api_key = os.environ.get("WHISP_API_KEY")
7
 
8
-
9
  # Define main function to fetch geojson, do API call and get statistics
10
 
11
  def get_statistics(file):
@@ -23,8 +23,11 @@ def get_statistics(file):
23
  # Do the API call
24
  whisp_response = whisp_request(geojson_file, api_key=whisp_api_key)
25
 
 
 
 
26
  # Do preprocessing
27
- return whisp_response
28
 
29
 
30
 
 
1
  import json
2
  import os
3
  from utils.whisp_api_client import whisp_request
4
+ from utils.whisp_preprocessing import preprocess_whisp_data
5
 
6
  # Import secrets
7
  whisp_api_key = os.environ.get("WHISP_API_KEY")
8
 
 
9
  # Define main function to fetch geojson, do API call and get statistics
10
 
11
  def get_statistics(file):
 
23
  # Do the API call
24
  whisp_response = whisp_request(geojson_file, api_key=whisp_api_key)
25
 
26
+ # Preprocess
27
+ preprocessed_response = preprocess_whisp_data(whisp_response)
28
+
29
  # Do preprocessing
30
+ return preprocessed_response
31
 
32
 
33
 
utils/whisp_preprocessing.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import openpyxl
3
+
4
+ def preprocess_whisp_data(response):
5
+
6
+ # Get whisp metadata
7
+ # whisp_metadata_url = "https://github.com/forestdatapartnership/whisp/blob/main/whisp_columns.xlsx"
8
+ # df_metadata = pd.read_excel(whisp_metadata_url, engine="openpyxl")
9
+
10
+ # Drop irrelevant entries
11
+ preprocessed_response = response['properties']
12
+
13
+ return preprocessed_response
14
+
15
+
16
+