Code:
@dataclass
class DataIngestionConfig:
train_data_path:str = os.path.join("artifacts/train_data")
test_data_path:str = os.path.join("artifacts/test_data")
raw_data_path:str = os.path.join('artifacts','raw.csv')
# permission denied on this address ^
class DataIngestionPhase:
def __init__(self):
self.dataIngestionConfig = DataIngestionConfig
def dataIngestion(self):
mlflow_logs = Mlflow_logs()
with mlflow.start_run():
logging.info("Data Ingestion Phase Start")
mlflow_logs.log_msg("Data Ingestion Phase Start")
try:
df = pd.read_csv("notebooks/data/Dataset.csv")
os.makedirs(os.path.join(self.dataIngestionConfig.raw_data_path), exist_ok=True)
df.to_csv(self.dataIngestionConfig.raw_data_path, index=False)
except Exception as e:
mlflow_logs.log_msg(f"Exception : {e}")
raise CustomException(e,sys)
Output :
[Errno 13] Permission denied: 'artifacts\\raw.csv']
I tried reading from a csv file and then storing it to a new csv file inside artifacts folder as raw.csv. Folder Permissions have already been granted yet I'm getting this error.
In os.makedirs
you are creating a folder named 'raw.csv'
inside 'artifacts'
raw_folder_path = 'artifacts'
os.makedirs(raw_folder_path, exist_ok=True)
df.to_csv(os.path.join(raw_folder_path, 'raw.csv'), index=False)