Load and dump data to json files
See original GitHub issueIt will be nice to have cli commands for importing/exporting data, something like:
$ lektor load file.csv
$ lektor dump model --otuput file.csv
It’ll be useful when importing data from other tools, spreadsheets, databases… etc
- It’s this ok?
- Should data be imported/exported from csv or json files?
If this gets approved I’m willing to provide a PR for it
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:15 (11 by maintainers)
Top Results From Across the Web
Python Tutorial: json.dump(s) & json.load(s) - 2021
There are two ways of reading in (load/loads) the following json file, in.json: ... import json data = json.dumps(d) print(type(data)) print(data). Output:
Read more >Reading and Writing JSON to a File in Python - Stack Abuse
In this tutorial, you'll learn how to parse, read, and write JSON to files in Python through examples, using load(), loads(), dump() and ......
Read more >Reading and Writing JSON to a File in Python - GeeksforGeeks
The JSON package in Python has a function called json.dumps() that helps in converting a dictionary to a JSON object. It takes two...
Read more >Python Read JSON File – How to Load ... - freeCodeCamp
First Approach: dump This is a function that takes two arguments: The object that will be stored in JSON format (for example, a...
Read more >How to Append Data to a JSON File in Python? [+Video] - Finxter
Method 1: Using json.load(file) and json.dump(data, file) · Import the json library with import json · Read the JSON file in a data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case anyone wants to take a crack at this a good place to start might be datamodel.py For instance it has several
to_json
methods that can do a lot of the exporting right now. Importing is another matter, but it’s a good jumping off point.For instance, play around in the
lektor dev shell
. Trypprint.pprint(pad.get('/').datamodel.to_json(pad))
Yes, load command will need some options (also dump), maybe something like this:
lektor load --model <model> --path <path> --format <json,csv> <file name>
lektor load --model blog --path /content/blog --format csv blog_dump.csv