Spaces:
Sleeping
Sleeping
Atharva Thakur
commited on
Commit
•
61e1f0d
1
Parent(s):
d14ee80
fixed the error
Browse files- app.py +6 -6
- data_loader.py +3 -16
app.py
CHANGED
@@ -13,13 +13,13 @@ import pandas as pd
|
|
13 |
|
14 |
def main():
|
15 |
st.title('Insights 📶')
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
load = data_loader.load_data()
|
19 |
-
if load:
|
20 |
-
data = pd.read_csv('data.csv')
|
21 |
-
|
22 |
-
|
23 |
|
24 |
if os.path.getsize("data.csv") != 0:
|
25 |
with st.sidebar:
|
|
|
13 |
|
14 |
def main():
|
15 |
st.title('Insights 📶')
|
16 |
+
data = pd.DataFrame()
|
17 |
+
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
18 |
+
if st.button('Load Data'):
|
19 |
+
data_loader = DataLoader()
|
20 |
+
data_loader.load_data(uploaded_file)
|
21 |
|
22 |
+
data = pd.read_csv("data.csv")
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
if os.path.getsize("data.csv") != 0:
|
25 |
with st.sidebar:
|
data_loader.py
CHANGED
@@ -6,25 +6,12 @@ class DataLoader:
|
|
6 |
pass
|
7 |
|
8 |
@st.cache_data(experimental_allow_widgets=True)
|
9 |
-
def load_data(_):
|
10 |
if True:
|
11 |
data = pd.DataFrame()
|
12 |
-
|
13 |
-
if data_source == 'Upload a CSV file':
|
14 |
-
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
15 |
-
if uploaded_file is not None:
|
16 |
data = pd.read_csv(uploaded_file)
|
17 |
data.to_csv('./original_data.csv', index=False)
|
18 |
data.to_csv('./data.csv',index=False)
|
19 |
-
return True
|
20 |
-
elif data_source == 'Input a URL':
|
21 |
-
url = st.text_input('Enter the URL of a CSV file')
|
22 |
-
if url:
|
23 |
-
try:
|
24 |
-
data = pd.read_csv(url)
|
25 |
-
data_loaded = True
|
26 |
-
except:
|
27 |
-
st.error('Could not load data from the provided URL. Please make sure the URL is correct and points to a CSV file.')
|
28 |
-
return True
|
29 |
print("data loader ran once")
|
30 |
-
return
|
|
|
6 |
pass
|
7 |
|
8 |
@st.cache_data(experimental_allow_widgets=True)
|
9 |
+
def load_data(_,uploaded_file):
|
10 |
if True:
|
11 |
data = pd.DataFrame()
|
12 |
+
if uploaded_file is not None:
|
|
|
|
|
|
|
13 |
data = pd.read_csv(uploaded_file)
|
14 |
data.to_csv('./original_data.csv', index=False)
|
15 |
data.to_csv('./data.csv',index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
print("data loader ran once")
|
17 |
+
return True
|