From e9975ebccd7fd740f2e8944cace7655215663f92 Mon Sep 17 00:00:00 2001 From: Ruchita Nathani Date: Sun, 5 Nov 2023 08:09:30 +0100 Subject: [PATCH] Added requests package to the dependencies in Pipfile and Added Absolute Path for Data file --- BDC/src/data_collector.py | 8 +++++--- Pipfile | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BDC/src/data_collector.py b/BDC/src/data_collector.py index 0e2823d..c641e63 100644 --- a/BDC/src/data_collector.py +++ b/BDC/src/data_collector.py @@ -3,6 +3,7 @@ import csv import requests import json +import os class DataCollector: @@ -13,7 +14,8 @@ def __init__(self): def get_data_from_csv(): """Retrieve information from the CSV file and utilize it in the Google API""" data = [] - with open('../data/given_data.csv', 'r', encoding='utf8') as file: + file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../data/given_data.csv') + with open(file_path, 'r', encoding='utf8') as file: csv_reader = csv.reader(file) next(csv_reader) @@ -39,8 +41,8 @@ def get_data_from_api(): if response.status_code == 200: data = response.json() - - with open("../data/collected_data.json", "w") as json_file: + file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../data/collected_data.json') + with open(file_path, "w") as json_file: user_data = [] for users in data["users"]: data_dict = { diff --git a/Pipfile b/Pipfile index 07baa54..1289b34 100644 --- a/Pipfile +++ b/Pipfile @@ -11,6 +11,7 @@ pytest = "==7.4.3" [packages] numpy = "==1.26.1" +requests = "*" [requires] python_version = "3.10"