[TW5] Can I create a bunch of tiddlers based on list?

362 views
Skip to first unread message

Mark S.

unread,
May 21, 2015, 2:26:51 PM5/21/15
to tiddl...@googlegroups.com
I would like to create a bunch of new tiddlers (preferably not in draft mode) from a list contained in a separate tiddler (it could be an existing data tiddler if necessary).

In other words, can I iterate through a list, generating new tiddlers?

I could do this sort of thing with the <javascript> tag in TWC.

The List widget allows me to do things the other way -- iterate over a list of existing tiddlers, but there doesn't seem to be any tools for generating a bunch of tiddlrs based on a list. I'm hoping there's some widget or technique that can help with this.

Thanks!
Mark

Eric Shulman

unread,
May 21, 2015, 2:47:50 PM5/21/15
to tiddl...@googlegroups.com
Actually, the <$list> widget WILL do what you want:

1) First, create a tiddler, ListOfTitles, containing tiddler titles using a whitespace-separate list with doubled-brackets around titles with spaces in them.  For example:

ListOfTitles
-------------------
[[foo bar]]
baz
[[mumble frotz]]
gronk
snork
---------------------

2) Then, use this button definition:
<$button>
make new tiddlers from list
<$list filter={{ListOfTitles}}>
<$action-setfield $tiddler={{!!title}} text=""/>
</$list>
</$button>
Note: using <$list> inside <$button> requires TW v5.1.8 or above.

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Måns

unread,
May 21, 2015, 4:12:31 PM5/21/15
to tiddl...@googlegroups.com
Hi Eric

GREAT :-)

Thank you very much for showing this simple solution for creating a lot of tiddlers from a simple list!

I can't help thinking that this sort of magic might allow for a little more complex things like converting a csv list of tiddler names, tags, standard and custom fields into tiddlers, simply by writing a simple macro with variables for each field in an action-setfield widget call...

I guess I'm just having a little daydream here - however It would be very, very nice to drag a csv file to a TW - click a button and kazaam - (example)  answers to your google docs forms are magically turned into tagged tiddlers with content... 

Cheers Måns Mårtensson

Eric Shulman

unread,
May 21, 2015, 4:27:09 PM5/21/15
to tiddl...@googlegroups.com
On Thursday, May 21, 2015 at 1:12:31 PM UTC-7, Måns wrote:
I can't help thinking that this sort of magic might allow for a little more complex things like converting a csv list of tiddler names, tags, standard and custom fields into tiddlers, simply by writing a simple macro with variables for each field in an action-setfield widget call...

This technique only works because ListOfTitles is essentially a hand-written filter containing literal tiddler titles.  If that tiddler also contained other data (i.e., CSV-formatted content on each line), then it would not be a valid filter and the <$list> widget would not work as intended.

sorry.

-e

Måns

unread,
May 21, 2015, 5:10:16 PM5/21/15
to tiddl...@googlegroups.com
It's still great :-)

RichardWilliamSmith

unread,
May 21, 2015, 8:14:36 PM5/21/15
to tiddl...@googlegroups.com
Hi Mans,

If you would like to create a lot of tiddlers from a spreadsheet, there's a simple method - put 'dummy' columns between your actual columns and fill them with the right json delimiters, paste the whole sheet as text into a file and save it and then drag it into TW. I can show you an example if you're interested.

Regards,
Richard

Måns

unread,
May 22, 2015, 10:53:47 AM5/22/15
to tiddl...@googlegroups.com
Hi Richard

If you would like to create a lot of tiddlers from a spreadsheet, there's a simple method - put 'dummy' columns between your actual columns and fill them with the right json delimiters, paste the whole sheet as text into a file and save it and then drag it into TW. I can show you an example if you're interested.

Yes please :-)

Cheers Måns Mårtensson 

Richard Smith

unread,
May 22, 2015, 11:20:38 PM5/22/15
to tiddl...@googlegroups.com
Hi Mans,

Starting with a spreadsheet - data in colums, no headers - put a blank column inbetween each, starting at the beginning and, in the top cell, add little snippets like this...

 {  "text": "

so that, as a whole, a single line of the spreadsheet reads as a valid json entry, with a comma at the end, and 'fill' down the sheet, so it looks like this...

Then copy and paste the columns into a friendly text editor (not a word-processor). When I do it I get some kind of 'tab' character that I need to globally remove (search and replace all). I've highlighted it in the top left of this screenshot.

Then I add opening and closing square brackets and save it as .json

Drag it into TW and it appears like a regular import.

NB: if there's anything wrong with your json, you get a big red warning but nothing breaks - but use a backup, obviously.

Regards,
Richard

Måns

unread,
May 23, 2015, 10:05:47 AM5/23/15
to tiddl...@googlegroups.com
Hi Richard

Thank you very much for taking your time to show how you do it :-)
Very helpfull!
Now I will need to do some experiments.

Is it also possible to create a "master" JSON tiddler/file which will be imported as a single tiddler where all defined tiddlers will exist/behave like shadow tiddlers?

I guess what I'm asking is how to turn the resulting JSON file into a plugin...

When I look at the $:/core tiddler it seems that all there is needed is one extra top layer: 
"{
    "tiddlers": {
"TiddlerTitle": {
            "title": "TiddlerTitle",
            "type": "text/vnd.tiddlywiki",
            "text": "Tiddler text with \n linebreaks"
        },
"NewTiddlerTitle": { ... etc...

If my assumption is correct it should be fairly easy to create a spredsheet like your's and make  the resulting JSON file create shadow tiddlers.

If this is possible I will maintain/update these shadow tiddlers with Andreas' Tinka plugin - and be able to import all these tiddlers into other TWs as if they were part of a plugin..

Am I on the right track?

Cheers Måns Mårtensson

Danielo Rodríguez

unread,
May 23, 2015, 10:27:03 AM5/23/15
to tiddl...@googlegroups.com
Mans, if you are interested and you are using Google spreadsheet it is not difficulttto write an script to export the data of a sheet as Json or tiddler format.

Richard Smith

unread,
May 23, 2015, 10:28:52 AM5/23/15
to tiddl...@googlegroups.com
Sounds good to me :)
I hope you'll share if you get it working - very interesting

Regards,
Richard

Måns

unread,
May 23, 2015, 1:48:45 PM5/23/15
to tiddl...@googlegroups.com
Hi Danielo

Of course I'm interested :-)
However I'm totally blank when it comes to writing a script to use with a Google spreadsheet.

I was thinking of having two seperate scripts one for creating a JSON file to import/create a lot of tiddlers at once - as Richard proposed - and another script which does almost the same except it creates "the extra layer" needed for it to be a standalone JSON tiddler which provides tiddlers as shadows....

Is this possible?

A naming convention for different tiddler fields might be set in the spreadsheet "header" columns like in a csv. like: title, tags(space or comma separated values), text, type,customfield1, customfield2, etc...?

Am I on the right track?

Cheers Måns Mårtensson

Danielo Rodríguez

unread,
May 23, 2015, 5:40:39 PM5/23/15
to tiddl...@googlegroups.com
Hello Mans,

Yes, it is possible to have a script that reads the sheet and creates a Json output. I don't know the best way to "export" that data: giving you the option to copy it? As a file in your drive folder? As am extra cell in some other sheet?

The easiest way to process the shet would be to represent a tiddler per row and make each colum be a field.

> it creates "the extra layer" needed for it to be a standalone JSON tiddler which provides tiddlers as shadows....

Sorry, I don't understand this requirement. For me a Json tiddler is a Json tiddler,the result is the same. The only thing that determines if it is a plugin or not are the field's the tiddler has.

RichardWilliamSmith

unread,
May 23, 2015, 6:47:49 PM5/23/15
to tiddl...@googlegroups.com
Hi Danielo,

My experience with trying to do that was that google sheets couldn't cope with exporting given the number of rows in my sheets and would keep falling over half-way through, which forced me to use apple-Numbers instead.

Regards,
Richard

Danielo Rodríguez

unread,
May 23, 2015, 9:10:03 PM5/23/15
to tiddl...@googlegroups.com
How many rows are we talking about? If there are so many I don't think TW can handle it neither.

RichardWilliamSmith

unread,
May 24, 2015, 1:44:20 AM5/24/15
to tiddl...@googlegroups.com
From what I remember it was around n=1200 rows - some sort of bug I suppose, perhaps it is fixed now? - batches of less than n worked fine. The original file had around 27,000 tiddlers - https://dl.dropboxusercontent.com/u/83055414/kjv.html

Regards,
Richard

stevesuny

unread,
Dec 31, 2015, 3:25:24 PM12/31/15
to TiddlyWiki
Hello all,

Reviving an old thread: 

Has anyone been able to import a google sheet as tiddlers, one tiddler per row, with columns for title, text, tags, etc? (essentially, replicating the functionality of  Eric Shulman's http://www.tiddlytools.com/#CreateTiddlersFromCSV for TW5?)? This thread contemplates a google sript to generate JSON, but export to CSV also makes sense to me...but still can import CSV one-tiddler-per-row...

Thanks, 

//steve.
Reply all
Reply to author
Forward
0 new messages