Skip to content

Commit 36f2d22

Browse files
committed
i/o close file fix
1 parent ee60027 commit 36f2d22

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gnsspy/io/readFile.py

+5
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def read_obsFile_v2(observationFile):
344344
else:
345345
interval = epochList[1] - epochList[0]
346346
interval = interval.seconds
347+
f.close() # close the file
347348
#---------------------------------------------------------------------------------------
348349
finish = time.time()
349350
print("Observation file ", observationFile," is read in", "{0:.2f}".format(finish-start), "seconds.")
@@ -553,6 +554,7 @@ def read_obsFile_v3(obsFileName):
553554
else:
554555
interval = epochList[1] - epochList[0]
555556
interval = interval.seconds
557+
f.close() # close the file
556558
# =============================================================================
557559
finish = time.time() # Time of finish
558560
print("Observation file ", obsFileName," is read in", "{0:.2f}".format(finish-start), "seconds.")
@@ -625,6 +627,7 @@ def read_sp3File(sp3file):
625627
position.index.name = 'SV'
626628
position.set_index('Epoch', append=True, inplace=True)
627629
position = position.reorder_levels(["Epoch","SV"])
630+
f.close() # close the file
628631
# ------------------------------------------------------------------
629632
end = time.time()
630633
print('{}'.format(sp3file), 'file is read in', '{0:.2f}'.format(end-start), 'seconds')
@@ -690,6 +693,7 @@ def read_clockFile(clkFile):
690693
SVtime.append(float(timelist[i][9]))
691694
SVTimelist = pd.DataFrame(list(zip(Epochlist, SVtime)), index = Sat,
692695
columns=['Epoch','DeltaTSV'])
696+
f.close() # close the file
693697
end = time.time()
694698
print('{}'.format(clkFile), 'file is read in', '{0:.2f}'.format(end-start), 'seconds')
695699
return SVTimelist
@@ -736,6 +740,7 @@ def read_ionFile(IonFile):
736740
del obsLines[0:6]
737741
del obsLines[0]
738742
#---------------------------------------------------------------------------------------
743+
f.close() # close the file
739744
finish = time.time()
740745
print("Ionosphere file ", IonFile," is read in", "{0:.2f}".format(finish-start), "seconds.")
741746
return tecuList

0 commit comments

Comments
 (0)