Commit e1f2ec62 authored by dasharatha.vamshi's avatar dasharatha.vamshi

forcast_data.csv

parent 4c3c1b24
...@@ -10,7 +10,8 @@ from scripts.common.logsetup import logger ...@@ -10,7 +10,8 @@ from scripts.common.logsetup import logger
class PreProcessComponent: class PreProcessComponent:
def __init__(self): def __init__(self):
self.ds, self.tempmax, self.tempmin, self.temp, self.humidity, self.precip, self.winddir, self.cloudcover, self.visibility, self.date, self.windspeed = ([] for i in range(11)) self.ds, self.tempmax, self.tempmin, self.temp, self.humidity, self.precip, self.winddir, self.cloudcover, self.visibility, self.date, self.windspeed = (
[] for i in range(11))
def read_pickle_file(self, file): def read_pickle_file(self, file):
try: try:
...@@ -50,7 +51,7 @@ class PreProcessComponent: ...@@ -50,7 +51,7 @@ class PreProcessComponent:
sc_X = self.read_pickle_file(standard_scalar_pkl_path) sc_X = self.read_pickle_file(standard_scalar_pkl_path)
X = sc_X.transform(forcast_data) X = sc_X.transform(forcast_data)
return X, self.date return X, self.date, forcast_data
if __name__ == '__main__': if __name__ == '__main__':
...@@ -85,7 +86,7 @@ if __name__ == '__main__': ...@@ -85,7 +86,7 @@ if __name__ == '__main__':
else: else:
raise Exception(ComponentExceptions.INVALID_Fillna_Method) raise Exception(ComponentExceptions.INVALID_Fillna_Method)
obj = PreProcessComponent() obj = PreProcessComponent()
data, date_pkl = obj.preprocess(json_path, standard_scalar_path, fillna_method) data, date_pkl, forcast_df = obj.preprocess(json_path, standard_scalar_path, fillna_method)
logger.info("Got the data writing it to pickle files (preprocessed_X.pkl and date_X.pkl)") logger.info("Got the data writing it to pickle files (preprocessed_X.pkl and date_X.pkl)")
try: try:
output = open(os.path.join(shared_volume, 'preprocessed_X.pkl'), 'wb') output = open(os.path.join(shared_volume, 'preprocessed_X.pkl'), 'wb')
...@@ -94,6 +95,8 @@ if __name__ == '__main__': ...@@ -94,6 +95,8 @@ if __name__ == '__main__':
output1 = open(os.path.join(shared_volume, 'date_X.pkl'), 'wb') output1 = open(os.path.join(shared_volume, 'date_X.pkl'), 'wb')
pickle.dump(date_pkl, output1) pickle.dump(date_pkl, output1)
output1.close() output1.close()
output2 = os.path.join(shared_volume, 'forcast_data.csv')
forcast_df.to_csv(output2, index=False)
logger.info("Component executed Successfully") logger.info("Component executed Successfully")
except Exception as e: except Exception as e:
raise Exception(e) raise Exception(e)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment