Spaces:
Sleeping
Sleeping
Commit
·
21b4681
1
Parent(s):
8f5f84f
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ from time import strftime, gmtime
|
|
4 |
import streamlit as st
|
5 |
from datetime import datetime, timedelta
|
6 |
import pandas as pd
|
7 |
-
import csv
|
8 |
from io import StringIO
|
9 |
|
10 |
# Function to fetch data from ShareASale
|
@@ -38,6 +37,12 @@ def parse_csv_to_df(csv_data):
|
|
38 |
csv_stream = StringIO(csv_data)
|
39 |
return pd.read_csv(csv_stream, delimiter='|')
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# Streamlit UI
|
42 |
st.title("Affiliate Earnings Dashboard")
|
43 |
st.sidebar.title("Settings")
|
@@ -51,9 +56,6 @@ api_secret_key = st.sidebar.text_input("API Secret Key", "YOUR_API_SECRET_KEY",
|
|
51 |
start_date = st.sidebar.date_input("Start Date", datetime.now() - timedelta(days=30))
|
52 |
end_date = st.sidebar.date_input("End Date", datetime.now())
|
53 |
|
54 |
-
# Load the merchantid to organisation name mapping
|
55 |
-
merchant_mapping = pd.read_csv('/mnt/data/a-599431.CSV') # Modify this path as needed
|
56 |
-
|
57 |
# Fetch data button
|
58 |
if st.sidebar.button("Fetch Data"):
|
59 |
# Fetch data from ShareASale
|
@@ -69,7 +71,7 @@ if st.sidebar.button("Fetch Data"):
|
|
69 |
# Filter rows where action is "Transaction Created"
|
70 |
df_filtered = df.loc[df['action'] == 'Transaction Created']
|
71 |
|
72 |
-
# Remove 'ledgerid' and '
|
73 |
df_filtered = df_filtered.drop(columns=['ledgerid', 'transid', 'action', 'merchantid'])
|
74 |
|
75 |
# Display the DataFrame as a table
|
|
|
4 |
import streamlit as st
|
5 |
from datetime import datetime, timedelta
|
6 |
import pandas as pd
|
|
|
7 |
from io import StringIO
|
8 |
|
9 |
# Function to fetch data from ShareASale
|
|
|
37 |
csv_stream = StringIO(csv_data)
|
38 |
return pd.read_csv(csv_stream, delimiter='|')
|
39 |
|
40 |
+
# Create a DataFrame for merchantid to organisation name mapping
|
41 |
+
merchant_mapping = pd.DataFrame({
|
42 |
+
'merchantid': [123, 456, 789], # Replace with your actual merchant IDs
|
43 |
+
'organisation name': ['Company A', 'Company B', 'Company C'] # Replace with your actual organisation names
|
44 |
+
})
|
45 |
+
|
46 |
# Streamlit UI
|
47 |
st.title("Affiliate Earnings Dashboard")
|
48 |
st.sidebar.title("Settings")
|
|
|
56 |
start_date = st.sidebar.date_input("Start Date", datetime.now() - timedelta(days=30))
|
57 |
end_date = st.sidebar.date_input("End Date", datetime.now())
|
58 |
|
|
|
|
|
|
|
59 |
# Fetch data button
|
60 |
if st.sidebar.button("Fetch Data"):
|
61 |
# Fetch data from ShareASale
|
|
|
71 |
# Filter rows where action is "Transaction Created"
|
72 |
df_filtered = df.loc[df['action'] == 'Transaction Created']
|
73 |
|
74 |
+
# Remove 'ledgerid', 'transid', and 'merchantid' columns
|
75 |
df_filtered = df_filtered.drop(columns=['ledgerid', 'transid', 'action', 'merchantid'])
|
76 |
|
77 |
# Display the DataFrame as a table
|