Spaces:
Sleeping
Sleeping
Update M1_Assignment2.py
Browse files- M1_Assignment2.py +20 -19
M1_Assignment2.py
CHANGED
@@ -21,41 +21,42 @@ def loading_dataset():
|
|
21 |
|
22 |
# LOADING BAR:
|
23 |
progress_bar = st.progress(2, text="Setting urls...")
|
24 |
-
|
|
|
25 |
# Defination of url-paths
|
26 |
-
url1 = 'https://github.com/aaubs/ds-master/raw/main/data/assignments_datasets/KIVA/kiva_loans_part_0.csv.zip'
|
27 |
-
url2 = 'https://github.com/aaubs/ds-master/raw/main/data/assignments_datasets/KIVA/kiva_loans_part_1.csv.zip'
|
28 |
-
url3 = 'https://github.com/aaubs/ds-master/raw/main/data/assignments_datasets/KIVA/kiva_loans_part_2.csv.zip'
|
29 |
|
30 |
# Loading the urls into requests to download data
|
31 |
progress_bar.progress(9, text="Downloading datasets...1/3")
|
32 |
-
response1 = requests.get(url1)
|
33 |
progress_bar.progress(32, text="Downloading datasets...2/3")
|
34 |
-
response2 = requests.get(url2)
|
35 |
progress_bar.progress(50, text="Downloading datasets...3/3")
|
36 |
-
response3 = requests.get(url3)
|
37 |
|
38 |
# Saves the .zip data as files
|
39 |
progress_bar.progress(55, text="Saving dataset zip-file...1/3")
|
40 |
-
with open("kiva_loans_part_0.csv.zip", "wb") as file:
|
41 |
-
file.write(response1.content)
|
42 |
progress_bar.progress(60, text="Saving dataset zip-file...2/3")
|
43 |
-
with open("kiva_loans_part_1.csv.zip", "wb") as file:
|
44 |
-
file.write(response2.content)
|
45 |
progress_bar.progress(65, text="Saving dataset zip-file...3/3")
|
46 |
-
with open("kiva_loans_part_2.csv.zip", "wb") as file:
|
47 |
-
file.write(response3.content)
|
48 |
|
49 |
# Unzip the files to get .csv
|
50 |
progress_bar.progress(70, text="Unzipping dataset...1/3")
|
51 |
-
with zipfile.ZipFile("kiva_loans_part_0.csv.zip", 'r') as zip_ref:
|
52 |
-
zip_ref.extractall()
|
53 |
progress_bar.progress(75, text="Unzipping dataset...2/3")
|
54 |
-
with zipfile.ZipFile("kiva_loans_part_1.csv.zip", 'r') as zip_ref:
|
55 |
-
zip_ref.extractall()
|
56 |
progress_bar.progress(81, text="Unzipping dataset...3/3")
|
57 |
-
with zipfile.ZipFile("kiva_loans_part_2.csv.zip", 'r') as zip_ref:
|
58 |
-
zip_ref.extractall()
|
59 |
|
60 |
# Loading partial datasets
|
61 |
progress_bar.progress(83, text="Importing partial datasets...")
|
|
|
21 |
|
22 |
# LOADING BAR:
|
23 |
progress_bar = st.progress(2, text="Setting urls...")
|
24 |
+
|
25 |
+
# PLEASE NOTICE - SOME PARTS HERE IS DISABLED DUE TO CSV FILES ARE ALREADY IN REPO !!!!
|
26 |
# Defination of url-paths
|
27 |
+
# url1 = 'https://github.com/aaubs/ds-master/raw/main/data/assignments_datasets/KIVA/kiva_loans_part_0.csv.zip'
|
28 |
+
# url2 = 'https://github.com/aaubs/ds-master/raw/main/data/assignments_datasets/KIVA/kiva_loans_part_1.csv.zip'
|
29 |
+
# url3 = 'https://github.com/aaubs/ds-master/raw/main/data/assignments_datasets/KIVA/kiva_loans_part_2.csv.zip'
|
30 |
|
31 |
# Loading the urls into requests to download data
|
32 |
progress_bar.progress(9, text="Downloading datasets...1/3")
|
33 |
+
# response1 = requests.get(url1)
|
34 |
progress_bar.progress(32, text="Downloading datasets...2/3")
|
35 |
+
# response2 = requests.get(url2)
|
36 |
progress_bar.progress(50, text="Downloading datasets...3/3")
|
37 |
+
# response3 = requests.get(url3)
|
38 |
|
39 |
# Saves the .zip data as files
|
40 |
progress_bar.progress(55, text="Saving dataset zip-file...1/3")
|
41 |
+
# with open("kiva_loans_part_0.csv.zip", "wb") as file:
|
42 |
+
# file.write(response1.content)
|
43 |
progress_bar.progress(60, text="Saving dataset zip-file...2/3")
|
44 |
+
# with open("kiva_loans_part_1.csv.zip", "wb") as file:
|
45 |
+
# file.write(response2.content)
|
46 |
progress_bar.progress(65, text="Saving dataset zip-file...3/3")
|
47 |
+
# with open("kiva_loans_part_2.csv.zip", "wb") as file:
|
48 |
+
# file.write(response3.content)
|
49 |
|
50 |
# Unzip the files to get .csv
|
51 |
progress_bar.progress(70, text="Unzipping dataset...1/3")
|
52 |
+
# with zipfile.ZipFile("kiva_loans_part_0.csv.zip", 'r') as zip_ref:
|
53 |
+
# zip_ref.extractall()
|
54 |
progress_bar.progress(75, text="Unzipping dataset...2/3")
|
55 |
+
# with zipfile.ZipFile("kiva_loans_part_1.csv.zip", 'r') as zip_ref:
|
56 |
+
# zip_ref.extractall()
|
57 |
progress_bar.progress(81, text="Unzipping dataset...3/3")
|
58 |
+
# with zipfile.ZipFile("kiva_loans_part_2.csv.zip", 'r') as zip_ref:
|
59 |
+
# zip_ref.extractall()
|
60 |
|
61 |
# Loading partial datasets
|
62 |
progress_bar.progress(83, text="Importing partial datasets...")
|