Skip to content

Commit

Permalink
using utf8 encoding for reading files
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimhamane committed Jan 17, 2024
1 parent 4d59396 commit b200142
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pyshbundle/new_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def read_itsg(file_path: str):

# open the file and read the lines
if file_path[-4:] == '.gfc':
with open(file_path, 'r') as file:
with open(file_path, 'r', encoding='utf8') as file:

# read the file line wise -> obtain a list of bytes
info_lines = file.readlines()
Expand Down Expand Up @@ -525,7 +525,7 @@ def read_tn13(file_path):
# check the file format - txt of zipped

if file_path[-4:] == '.txt':
with open(file_path, 'r') as file:
with open(file_path, 'r', encoding='utf8') as file:

# read the file line wise -> obtain a list of bytes
info_lines = file.readlines()
Expand Down Expand Up @@ -655,7 +655,7 @@ def read_tn14(file_path):

# read the data into a list
if file_path[-4:] == '.txt':
with open(file_path, 'r') as file:
with open(file_path, 'r', encoding='utf8') as file:

# read the file line wise -> obtain a list of bytes
info_lines = file.readlines()
Expand Down
4 changes: 2 additions & 2 deletions pyshbundle/reader_replacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def reader_replacer(path, path_tn14, path_tn13):


rep_start_date, rep_end_date, c20, c30 = [], [], [], []
with open(new_file_TN14,"r") as file:
with open(new_file_TN14,"r", encoding='utf8') as file:
stuff = file.readlines()
for i in range(0,len(stuff),1):
if stuff[i] == str('Product:\n'):
Expand Down Expand Up @@ -209,7 +209,7 @@ def reader_replacer(path, path_tn14, path_tn13):
new_file_TN13 = path_tn13

rep_start_date_deg1, rep_end_date_deg1, c1m, s1m = [], [], [], []
with open(new_file_TN13,"r") as file:
with open(new_file_TN13,"r", encoding='utf8') as file:
stuff = file.readlines()
for i in range(0,len(stuff),1):
if stuff[i] == str('end of header ===============================================================================\n'):
Expand Down
6 changes: 3 additions & 3 deletions pyshbundle/reader_replacer_itsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def reader(file_name,line_num,degree,order,clm,slm,clm_std,slm_std,start_date,ye
year_start (_type_): _description_
time_axes (_type_): _description_
"""
with open(file_name,"r") as file:
with open(file_name,"r", encoding='utf8') as file:
stuff = file.readlines()
stuff
for i in range (0,len(stuff),1):
Expand Down Expand Up @@ -173,7 +173,7 @@ def reader_replacer_itsg(path, path_tn14, path_tn13):
new_file_TN14 = path_tn14

rep_start_date, rep_end_date, c20, c30, c20_sigma, c30_sigma = [], [], [], [], [], []
with open(new_file_TN14,"r") as file:
with open(new_file_TN14,"r", encoding='utf8') as file:
stuff = file.readlines()
for i in range(0,len(stuff),1):
line_num = str('not found')
Expand Down Expand Up @@ -225,7 +225,7 @@ def reader_replacer_itsg(path, path_tn14, path_tn13):
''' Replace deg 1 '''
new_file_TN13 = path_tn13
rep_start_date_deg1, rep_end_date_deg1, c1m, s1m, c1m_sigma, s1m_sigma = [], [], [], [], [], []
with open(new_file_TN13,"r") as file:
with open(new_file_TN13,"r", encoding='utf8') as file:
stuff = file.readlines()
for i in range(0,len(stuff),1):
if stuff[i] == str('end of header ===============================================================================\n'):
Expand Down
4 changes: 2 additions & 2 deletions pyshbundle/reader_replacer_jpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def reader_replacer_jpl(path, path_tn14, path_tn13):
new_file_TN14 = path_tn14

rep_start_date, rep_end_date, c20, c30, c20_sigma, c30_sigma = [], [], [], [], [], []
with open(new_file_TN14, "r") as file:
with open(new_file_TN14, "r", encoding='utf8') as file:
stuff = file.readlines()
for i in range(0, len(stuff), 1):
line_num = str('not found')
Expand Down Expand Up @@ -228,7 +228,7 @@ def reader_replacer_jpl(path, path_tn14, path_tn13):
''' Replace deg 1 '''
new_file_TN13 = path_tn13
rep_start_date_deg1, rep_end_date_deg1, c1m, s1m, c1m_sigma, s1m_sigma = [], [], [], [], [], []
with open(new_file_TN13, "r") as file:
with open(new_file_TN13, "r", encoding='utf8') as file:
stuff = file.readlines()
for i in range(0, len(stuff), 1):
if stuff[i] == str('end of header ===============================================================================\n'):
Expand Down

0 comments on commit b200142

Please sign in to comment.