Abu1998 commited on
Commit
fb157f4
·
verified ·
1 Parent(s): 5b03666

Update dataset_import.py

Browse files
Files changed (1) hide show
  1. 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 load_data(dataset_url):
6
- # Download the dataset from the Kaggle URL provided
7
- dataset_name = dataset_url.split('/')[-1]
8
- os.system(f"kaggle datasets download -d {dataset_url} -p ./data --unzip")
 
 
 
 
 
 
 
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
- dataset_url = st.text_input("Enter the Kaggle Dataset URL")
23
- if dataset_url:
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()