From b20014273fed4e80bf6f093297a55e8bb7f0aa14 Mon Sep 17 00:00:00 2001 From: Abhishek Mhamane Date: Wed, 17 Jan 2024 17:57:22 +0530 Subject: [PATCH] using utf8 encoding for reading files --- pyshbundle/new_io.py | 6 +++--- pyshbundle/reader_replacer.py | 4 ++-- pyshbundle/reader_replacer_itsg.py | 6 +++--- pyshbundle/reader_replacer_jpl.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pyshbundle/new_io.py b/pyshbundle/new_io.py index b4eac1bd..d570eec4 100644 --- a/pyshbundle/new_io.py +++ b/pyshbundle/new_io.py @@ -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() @@ -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() @@ -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() diff --git a/pyshbundle/reader_replacer.py b/pyshbundle/reader_replacer.py index e229e1c2..ee0c7dbb 100644 --- a/pyshbundle/reader_replacer.py +++ b/pyshbundle/reader_replacer.py @@ -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'): @@ -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'): diff --git a/pyshbundle/reader_replacer_itsg.py b/pyshbundle/reader_replacer_itsg.py index 7688e568..3e56d319 100644 --- a/pyshbundle/reader_replacer_itsg.py +++ b/pyshbundle/reader_replacer_itsg.py @@ -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): @@ -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') @@ -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'): diff --git a/pyshbundle/reader_replacer_jpl.py b/pyshbundle/reader_replacer_jpl.py index ceaba079..ef371e57 100644 --- a/pyshbundle/reader_replacer_jpl.py +++ b/pyshbundle/reader_replacer_jpl.py @@ -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') @@ -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'):