= <some_dir> / "some_file.json"
output_path = {'a': 1, 'b': 2}
params with output_path.open('w') as f:
=4) # `indent` writes each new input on a new line json.dump(params, f, indent
FileIO
JSON
To dump data to json file:
to load from json file:
with input_path.open() as f:
= json.load(f) result
shutil
shutil.copy(src_path, dst_path)from shutil import copyfile, rmtree, move
CSV
import csv
def read_csv_file_into_dict(filename):
with open(filename, newline='') as csvfile:
= csv.reader(csvfile, delimiter=',')
reader = {row[0]: row[1] for row in reader}
x return x
Readline
and Readlines
with open(f, "r") as f:
a = f.readlines()