Last active
June 2, 2022 06:49
-
-
Save nitishxp/e7ab205ec3e1c25cbd83d5a6e39b6d32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will create a ndjson file | |
# input -> path to the json file | |
import json | |
filepath = input("enter complete path of the file ") | |
with open(filepath, "r") as read_file: | |
data = json.load(read_file) | |
new_file = f"{filepath.rsplit('.json')[0]}.ndjson" | |
result = [json.dumps(record) for record in data] | |
with open(new_file, 'w') as obj: | |
for i in result: | |
obj.write(i + '\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment