I added below code to a script and it works all fine to remove the illeagal characters
Below is original codes which works fine in a script without lots functions or definitions:
def remove_illegal_chars(s):
if isinstance(s, str):
return re.sub(r'[x00-x1Fx7F-x9F]', '', s)
return s
df = df.applymap(remove_illegal_chars)```
And then I needed to add this into another script that had illegal character problem as well. But it didn't work, the illeagal character error still happen, it seems this line "dfC = dfC.applymap(remove_illegal_chars)" added into another function didn't work properly... any suggestions please?
def remove_illegal_chars(s):
if isinstance(s, str):
return re.sub(r'[x00-x1Fx7F-x9F]’, ”, s)
return s
def get_txt(instrFilePath):
try:
#
sys.path.insert(1, in_ModulePyFileFolderPath)
import A_Functions
df = A_Functions.add_to_main_DataFrame(instrFilePath)
df = df.applymap(remove_illegal_chars) #I think this remove function is not called properly...
....lots other code skipped here as they work fine.....
except Exception as errorMessage:
returnError='Error Occurred while Parsing Receipt. Exception: '+str(errorMessage)
return returnError```
Remove illeagal character function to be working inside another function, but I can’t instal xlsxwriter
Mmm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.