import json
import os.path

with open('profile.csv') as fp:
    for l in fp:
        fn = l.split(',')[0]
        with open(fn, encoding='utf-8') as js:
            data = []
            for item in json.load(js):
                if item['cat'] != 'chat':
                    data.append(item)
            with open(os.path.join('wos-data-sanitized', os.path.basename(fn)), 'w') as out:
                json.dump(data, out)
                print("Finish: ", fn)
