File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,12 @@ def read_bsrn(filename):
94
94
else :
95
95
open_func , mode = open , 'r'
96
96
with open_func (filename , mode ) as f :
97
- for num , line in enumerate (f ):
98
- if num == 1 : # Get month and year from the 2nd line
99
- start_date = pd .Timestamp (year = int (line [7 :11 ]),
100
- month = int (line [3 :6 ]), day = 1 ,
101
- tz = 'UTC' ) # BSRN timestamps are UTC
97
+ f .readline () # first line should be *U0001, so read it and discard
98
+ line_no_dict ['0001' ] = 0
99
+ date_line = f .readline () # second line contains the year and month
100
+ start_date = pd .Timestamp (year = int (date_line [7 :11 ]),
101
+ month = int (date_line [3 :6 ]), day = 1 ,
102
+ tz = 'UTC' ) # BSRN timestamps are UTC
102
103
if line .startswith ('*' ): # Find start of all logical records
103
104
line_no_dict [line [2 :6 ]] = num # key is 4 digit LR number
104
105
You can’t perform that action at this time.
0 commit comments