0

I have written a python script which remove's special characters (*/§) from a JSON file and then put into another folder without changing name.

Here is code:

import json

with open('ORIGINAL PATH WHERE JSON FILE IS STORED’, encoding='utf-8-sig') as json_file: FILE-NAME = json.load(json_file)

import re

Open = re.sub('[*//$§%!]', '', str(Open))
with open('ORIGINAL PATH WHERE JSON FILE IS STORED’, 'w') as f:
    json.dump(FILE-NAME, f, ensure_ascii=False)

import shutil, sys

shutil.move("ORIGINAL PATH WHERE JSON FILE IS STORED", "'NEW PATH WHERE YOU WANT TO STORE JSON FILE")

It is working fine for a single JSON file. My problem is, I have more than 1000 JSON files in a folder, I want to remove special characters (*/ § $) from all the files without changing name of JSON files.

Amir
  • 27
  • 2
  • Possible duplicate of [How can I iterate over files in a given directory?](https://stackoverflow.com/questions/10377998/how-can-i-iterate-over-files-in-a-given-directory) – voiDnyx Oct 25 '17 at 13:49
  • do you have difficulties to make a function of your code or to get the list of files in a directory ? – Cédric Julien Oct 25 '17 at 13:49
  • I could not figure out how to make function of my code: @CédricJulien – Amir Oct 25 '17 at 14:05

0 Answers0