question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load and dump data to json files

See original GitHub issue

It 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:open
  • Created 6 years ago
  • Reactions:1
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
nixjdmcommented, May 18, 2018

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. Try pprint.pprint(pad.get('/').datamodel.to_json(pad))

1reaction
rlaverdecommented, Nov 21, 2017

Also, lektor load file.csv reads like a pretty broadly scoped command. Where do you envision this being imported to? Will that be encoded in the csv? CLI options could let you specify what to do with it.

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found