|
import os
|
|
import sys
|
|
|
|
from recommendationSystem.logging import logger
|
|
from recommendationSystem.utils.common import CustomException
|
|
from recommendationSystem.config.configuration import DataIngestionConfig
|
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
class DataIngestion:
|
|
def __init__(self):
|
|
self.ingestion_config = DataIngestionConfig()
|
|
|
|
def initiate_data_ingestion(self):
|
|
|
|
logger.info("Entered the Data Ingestion method")
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
anime = pd.read_csv(os.path.join("data","anime_data_7490.csv"))
|
|
logger.info("Read the dataset as a dataframe")
|
|
|
|
|
|
os.makedirs(os.path.dirname(self.ingestion_config.data_path),exist_ok=True)
|
|
logger.info("created directory for datframe")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
anime['tags'] = anime['sypnopsis']+" " + anime['type']+" " + anime['episodes']+" " \
|
|
+ anime['status'] +" "+ anime['studios'] +" "+ anime['source']+" " + anime['genres']+" " + anime['demographic']
|
|
|
|
|
|
anime.to_csv(self.ingestion_config.data_path,index=False,header=True)
|
|
logger.info("Ingestion is completed")
|
|
logger.info("---------------x DIRECTORY CHANGE x------------------")
|
|
|
|
|
|
return(
|
|
self.ingestion_config.data_path
|
|
)
|
|
|
|
except Exception as e:
|
|
raise CustomException(e,sys) |