Skip to content

Commit

Permalink
Adding pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-George-T committed Oct 18, 2023
1 parent 47b744f commit d1ba34a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
Binary file modified src/__pycache__/datapipeline.cpython-310.pyc
Binary file not shown.
40 changes: 24 additions & 16 deletions src/datapipeline.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
import requests
"""
Functions to ingest and process data
"""
import zipfile
import requests

def ingest_data():

file_url = "https://archive.ics.uci.edu/static/public/352/online+retail.zip"
"""
Function to download file from URL
"""
file_url = "https://archive.ics.uci.edu/static/public/352/online+retail.zip"

# Send an HTTP GET request to the URL
response = requests.get(file_url)
# Send an HTTP GET request to the URL
response = requests.get(file_url, timeout=30)

# Check if the request was successful (status code 200)
if response.status_code == 200:
# Save file to data
with open("data/data.zip", "wb") as file:
file.write(response.content)
print("File downloaded successfully.")
else:
print(f"Failed to download the file. Status code: {response.status_code}")
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Save file to data
with open("data/data.zip", "wb") as file:
file.write(response.content)
print("File downloaded successfully.")
else:
print(f"Failed to download the file. Status code: {response.status_code}")


def unzip_file():
"""
Function to unzip the downloaded data
"""
zip_filename ='data/data.zip'
extract_to = 'data/'
try:
with zipfile.ZipFile(zip_filename, 'r') as zip_ref:
zip_ref.extractall(extract_to)
print(f"File {zip_filename} successfully unzipped to {extract_to}")
except Exception as e:
print(f"Failed to unzip {zip_filename}: {e}")
except zipfile.BadZipFile:
print(f"Failed to unzip {zip_filename}")


if __name__ == "__main__":
ingest_data()
unzip_file()
unzip_file()

0 comments on commit d1ba34a

Please sign in to comment.