So I have occurrence of strings starting with \u followed by various forms of 4 character hexadecimals (They are not unicode objects, but actual strings in the data, which is why I would like to clean up the data) and would like to replace that occurrences with white spaces.
Example textfile: Hello \u2022 Created, reviewed, \u00e9executed and maintained
For eg: there would be occurrences of strings \u2022 and \u00e9, I would like to find \u and remove it along with the 4 character substring 2022 and 00e9 followed after that. I'm looking for an adequate regex for this pattern.
Example Code:
import json
import io
import re
files = glob('Candidate Profile Data/*')
for file_ in files:
with io.open(file_, 'r', encoding='us-ascii') as json_file:
json_data = json_file.read().decode()
json_data = re.sub('[^\x00-\x7F]+',' ',json_data)
json_data = json_data.replace('\\n',' ')
json_data = re.sub(r'\\u[0-9a-f]{,4}',' ',json_data)
print json_data
json_data = json.loads(json_data)
print(json_data)