Skip to content

Instantly share code, notes, and snippets.

@rohanbk
Created March 30, 2020 20:57
Show Gist options
  • Save rohanbk/f905f6da25823a0faa83d0470a59dae9 to your computer and use it in GitHub Desktop.
Save rohanbk/f905f6da25823a0faa83d0470a59dae9 to your computer and use it in GitHub Desktop.
date_bentos = {}
""" format of csv being processed is
Affected Bentos,Incident Date
app1a;app1b;app1c;app1d;app1e;app1f,3/18/2020
app1d,3/16/2020
app1a;app1b;app1c;app1d;app1f,3/17/2020
app1a;app1b;app1c;app1d;app1e;app1f;app2a;app2b,3/16/2020
app1c,3/13/2020
app1c,3/16/2020
"""
with open("bento-date.csv", 'r') as file_in:
i=0
# line = app1a;app1b;app1c;app1d;app1e;app1f,3/18/2020
for line in file_in:
# skip csv header
if i==0:
i+=1
continue
incident = line.split(',') # incident = ['app1a;app1b;app1c;app1d;app1e;app1f','3/18/2020']
affected_bentos = incident[0].split(';') #affected_bentos = ['app1a','app1b',...'app1f']
date = incident[1].replace('\n','') # date = 3/17/2020
for bento in affected_bentos:
print(date+","+bento)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment