maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
226 stars 24 forks source link

Dump existing item as JSON #68

Closed antifa-ev closed 4 years ago

antifa-ev commented 6 years ago

How can I dump an existing item as JSON?

I would like to create new items from csv column data while using JSON 'skeleton' files. Have you once tried something? wd edit-item ./new_item_data.json

maxlath commented 6 years ago

(if I got your question correctly) you can use the simplified output of wd data as a squeleton: wd data --simplify Q80 > skeleton.json

It easier to use if pretty printed, which can be done using a tool such as jq or jd:

You can then edit the squeleton to fit your needs and edit the entity: wd edit-item ./skeleton.json

antifa-ev commented 6 years ago

I've had to use wd data --simplify Q80 | jq -r . | cat > skeleton.json because of https://github.com/stedolan/jq/issues/1110 Weird issue ...

maxlath commented 5 years ago

I just published v7.3.0, which includes a new command based on this idea of preparing a skeleton or template from an existing item: wd generate-template. Could you give it a try to tell me if that meets your expectations?