generated from geohackweek/sample_project_repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparsepicks.py
27 lines (23 loc) · 895 Bytes
/
parsepicks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import csv
def parse_input_file(filename):
request = {}
for t in ['EQS','EQP','SUS','SUP','THS','THP','SNS','SNP','PXS','PXP']:
request[t] = []
with open(filename) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
pick = {}
pick['event_type'] = row[0].strip()
pick['time'] = row[1].strip()
pick['sta'] = row[2].strip()
pick['net'] = row[3].strip()
pick['loc'] = row[4].strip()
pick['chan'] = row[5].strip()
pick['pick_type'] = row[6].strip()
pick['quality'] = row[7].strip()
pick['who'] = row[8].strip()
#print(pick)
key = "{}{}".format(pick['event_type'], pick['pick_type'])
request[key].append(pick)
return request
res = parse_input_file('arrivals.csv')