initial commit
This commit is contained in:
22
utils/pickle2json.py
Normal file
22
utils/pickle2json.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import json
|
||||
import pickle
|
||||
import sys
|
||||
|
||||
files = sys.argv[1:]
|
||||
print(files)
|
||||
|
||||
for pickle_filename in files:
|
||||
if not pickle_filename.endswith('.pickle'):
|
||||
print(pickle_filename + ' is not a pickle. ignoring')
|
||||
continue
|
||||
|
||||
with open(pickle_filename, 'rb') as file:
|
||||
obj = pickle.load(file)
|
||||
print(obj)
|
||||
|
||||
json_filename = pickle_filename[0:-6] + 'json'
|
||||
try:
|
||||
with open(json_filename, 'w') as file:
|
||||
json.dump(obj, file)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Reference in New Issue
Block a user