Created
December 13, 2020 09:03
-
-
Save audhiaprilliant/0f1bf02b8d65678f2f1d07fd99dec160 to your computer and use it in GitHub Desktop.
Apache Airflow as Job Orchestration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function to save the daily aggregated data | |
| def summary_save_txt(**context): | |
| value = context['task_instance'].xcom_pull(task_ids = 'summary_scraping_data') | |
| with open(dir_path+'/data/covid19/summary_covid19.txt','r') as f: | |
| lines = f.read().splitlines() | |
| last_line = lines[-1] | |
| if last_line == value: | |
| notif = 'Last update:',re.findall(r'^(.+?),',last_line)[0] | |
| else: | |
| with open(dir_path+'/data/covid19/summary_covid19.txt','a+') as ff: | |
| ff.write('{}\n'.format(value)) | |
| ff.close() | |
| notif = 'Up to date data:', re.findall(r'^(.+?),',value)[0] | |
| return(notif) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment