Escapes or unescapes a JSON string removing traces of offending characters that could prevent parsing.
The following characters are reserved in JSON and must be properly escaped to be used in strings:
Backspace is replaced with \b
Form feed is replaced with \f
Newline is replaced with \n
Carriage return is replaced with \r
Tab is replaced with \t
Double quote is replaced with \"
Backslash is replaced with \\
import pandas as pd
# Get the list of json files, which are in the folder:
str_address = r"/media/New Volume/a3d/pdb/json_parser/"
lst_files = [i for i in os.listdir(str_address) if i.endswith(".json")]
# Loop through the json files
for file_ in lst_files:
df = pd.read_json(str_address + file_)
df.to_csv(str_address+ file_+ ".txt", index = False)