Skip to content

Instantly share code, notes, and snippets.

@nitishxp
Last active June 2, 2022 06:49
Show Gist options
  • Save nitishxp/e7ab205ec3e1c25cbd83d5a6e39b6d32 to your computer and use it in GitHub Desktop.
Save nitishxp/e7ab205ec3e1c25cbd83d5a6e39b6d32 to your computer and use it in GitHub Desktop.
# 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