Skip to content

Commit 63dd3ac

Browse files
Handle file start date explicitly
Co-authored-by: Will Holmgren <[email protected]>
1 parent 536f53c commit 63dd3ac

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pvlib/iotools/bsrn.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ def read_bsrn(filename):
9494
else:
9595
open_func, mode = open, 'r'
9696
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
102103
if line.startswith('*'): # Find start of all logical records
103104
line_no_dict[line[2:6]] = num # key is 4 digit LR number
104105

0 commit comments

Comments
 (0)