Spaces:
Sleeping
Sleeping
Update dataset_import.py
Browse files- dataset_import.py +13 -8
dataset_import.py
CHANGED
@@ -2,10 +2,17 @@ import os
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
-
def
|
6 |
-
#
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# List available files in the data directory
|
11 |
available_files = [f for f in os.listdir('./data') if f.endswith('.csv')]
|
@@ -19,10 +26,8 @@ def load_data(dataset_url):
|
|
19 |
|
20 |
def main():
|
21 |
st.title("Kaggle Dataset Loader")
|
22 |
-
|
23 |
-
|
24 |
-
data = load_data(dataset_url)
|
25 |
-
st.write(data.head())
|
26 |
|
27 |
if __name__ == "__main__":
|
28 |
main()
|
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
+
def download_dataset():
|
6 |
+
# Ensure the data directory exists
|
7 |
+
if not os.path.exists('./data'):
|
8 |
+
os.makedirs('./data')
|
9 |
+
|
10 |
+
# Download the dataset using Kaggle API
|
11 |
+
os.system("kaggle datasets download -d mohaideenabuthahir/analyzeyt -p ./data --unzip")
|
12 |
+
|
13 |
+
def load_data():
|
14 |
+
# Ensure dataset is downloaded
|
15 |
+
download_dataset()
|
16 |
|
17 |
# List available files in the data directory
|
18 |
available_files = [f for f in os.listdir('./data') if f.endswith('.csv')]
|
|
|
26 |
|
27 |
def main():
|
28 |
st.title("Kaggle Dataset Loader")
|
29 |
+
data = load_data()
|
30 |
+
st.write(data.head())
|
|
|
|
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
main()
|