File size: 1,046 Bytes
aa0cd67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pandas as pd
import streamlit as st

def process_dataframe(ods_file):
    try:
        # Read the .ods file into a DataFrame
        df = pd.read_excel(ods_file, engine='odf')

        # Clean up unnecessary columns and rows
        df.drop(columns=["Unnamed: 0", "Unnamed: 1"], inplace=True, errors='ignore')
        df.dropna(how='all', inplace=True)
        df.reset_index(drop=True, inplace=True)

        # Identify and set the header row
        for idx, row in df.iterrows():
            if row['Unnamed: 2'] == 'Application Number' and row['Unnamed: 3'] == 'Decision':
                df.columns = ['Application Number', 'Decision']
                df = df.iloc[idx + 1:]
                break

        # Convert application numbers to strings
        df.reset_index(drop=True, inplace=True)
        df['Application Number'] = df['Application Number'].astype(str)
        return df
    except Exception as e:
        st.error(f"Error processing the data: {e}")
        return pd.DataFrame()  # Return an empty DataFrame on failure