Import and Export CSV to Tiddlers and vice versa?

804 views
Skip to first unread message

rpnfan

unread,
Apr 18, 2009, 4:35:44 PM4/18/09
to TiddlyWiki
Hi,

I'm new to TiddlyWiki and have searched if there is an option/plugin
or external solution or any help to export or import all Tiddlers to a
CSV format file? Before I dive into a new system I like to be sure
that data entered can be reused later when I wish/need that :-)

My wish is to import/export

Tiddlername, Tiddler-Content, Tiddler-Tabs (separeted with a definable
separation char)

to/from a CSV file.

Looking forward your ideas and pointers.

Best regards
Peter

Måns

unread,
Apr 18, 2009, 5:31:51 PM4/18/09
to TiddlyWiki
Hi rpnfan

Eric Shulman has made this plugin:
http://www.tiddlytools.com/#CreateTiddlersFromCSV

It works very well!

I'm using it to import all students and teachers (less than 200) from
my school, to tiddlers in one go -
I specify tiddlertitles, tags (spaceseperated list) and fieldvalues
(for custom fieldnames)
I've even implemented a google spreadsheet in my CreateTiddlersFromCSV-
tiddler.
It exports to csv directly in the browser and there's no need for a
program..

Regards Måns Mårtensson

Måns

unread,
Apr 18, 2009, 5:35:19 PM4/18/09
to TiddlyWiki
Oh I forgot to say:
There's a limitation for importing to the textfield - It cannot
interpret commas in the text - not even if it's isolated in some way -
so you have to be carefull - and remove all commas from textfields...

Regards Måns Mårtensson

Måns

unread,
Apr 18, 2009, 9:53:52 PM4/18/09
to TiddlyWiki
I forgot "versa".
I use ForEachTiddlerPlugin (http://tiddlywiki.abego-software.de/
#ForEachTiddlerPlugin) to fetch the data i various ways.
To write a csv file, or to make tables like this for a table of the
relevant tiddlers with correct columntitles and order:
<<forEachTiddler
where
'tiddler.tags.contains("TagName")'
sortBy 'tiddler.title'
write
'(index < 200) ? "|"+(index+1)+"|[["+tiddler.title+"]]|"+tiddler.body
+"|"+tiddler.tags+"| [["+tiddler.fields["1'stFieldnameOfYourChoice"]
+"]] |"+tiddler.fields["2'ndFieldnameOfYourChoice"]+"|"+tiddler.fields
["3'dFieldnameOfYourChoice"]+"|"+tiddler.fields
["5'thFieldnameOfYourChoice"]+"|"+tiddler.fields
["6'thFieldnameOfYourChoice"] +"|\n" : ""'
begin '"|sortable|k\n|!#|title|text|tags|
1'stFieldnameOfYourChoice|2'nd|3'd|4'th|5'th|h\n"'
end 'count+" tiddlers\n"'
none '"no tiddlers\n"'
>>

Or csv directly - Sorry, but I don't know how to get more than just
the titles in one row:

<<forEachTiddler
where
'tiddler.tags.contains("TagName")'
write
'((index == 0) ? "" : ", ")+"[["+tiddler.title+"]]"'
>>

YS Måns Mårtensson

Eric Shulman

unread,
Apr 20, 2009, 1:54:06 PM4/20/09
to TiddlyWiki

I've added built-in support for CSV output to both these plugins:

http://www.TiddlyTools.com/#SaveAsPlugin (v2.5.0)
http://www.TiddlyTools.com/#ExportTiddlersPlugin (v2.9.0)

Currently, they only output standard tiddler data (title, modifier,
created, modified, text, and tags). The primary issue is that the
number and names of the custom fields can vary from tiddler to
tiddler, so generating useful row-and-column output in CSV is somewhat
more difficult... but I'm working on it.

Also, any values containing commas are automatically "CSV encoded" by
enclosing them in quotes (so the commas are treated as data, not
separators). In addition, any quotes contained within the value
itself are doubled up (e.g., " becomes "") to distinguish them from
the quotes that are being used to enclose the value. For example:

He said, "yabba, dabba, doo"

would be written out as:

"He said, ""yabba, dabba, doo"""

Although it might look a bit strange, the extra quotes are
automatically removed when loading in the data into most spreadsheets
and databases, allowing you to import the CSV-formatted tiddler data
directly into those applications.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Måns

unread,
Apr 20, 2009, 5:05:51 PM4/20/09
to TiddlyWiki
Hi Eric
I say, "yabba, dabba, doo" ...
Great job!!

I look forward for the ability to get fields into the csv as well.

YS Måns Mårtensson

Eric Shulman

unread,
Apr 24, 2009, 12:08:26 PM4/24/09
to TiddlyWiki
> There's a limitation for importing to the textfield - It cannot
> interpret commas in the text - not even if it's isolated in some way -
> so you have to be carefull - and remove all commas from textfields...

[[CreateTiddlersFromCSV]] has been updated and now correctly handles
CSV-encoded fields containing commas and/or double-quotes. The CSV-
encoding rule is very simple:

If a field contains any commas or double-quotes, surround the entire
field in double-quotes and then double-up any quotes contained within
the field.

Thus, this:
some "quoted" text, with a comma
would become:
"some ""quoted"" text, with a comma"

Note: if you using CSV data generated from a spreadsheet, this CSV-
encoding is done automatically.

Get the update (v1.1.0) here:
http://www.tiddlytools.com/#CreateTiddlersFromCSV

enjoy,
-e

Måns

unread,
Apr 24, 2009, 1:24:03 PM4/24/09
to TiddlyWiki
Thank you Eric - This update is great and very welcome!!

YS Måns Mårtensson

rpnfan

unread,
Apr 24, 2009, 2:15:09 PM4/24/09
to TiddlyWiki
Thank you Eric and Måns :-)

it looks my wish comes true. Thank you very much for your help.

Although I was still strugglin' to get the Plugin working. I did not
find a documentation for the plugin and tried several options how a
CSV file could look like. I assumed somthing like

TiddlerTitleToImport,""Text to be imported, with a comma in the
text"",tags separated by space

or something like that. When I pasted the above (or other CSV
variants) to the import field and I click on "create tiddler" I always
got error messages or nothing happend (only a message that 0 tiddlers
are generated).

Ah, then in a last attempt I though I should try to _export_ to CSV
and look what the structure is. So now I was more successful :)

title,tags,text
MyTestImportTitle,TestTag AnotherTestTag,""Hi ho"," said the clown""
MyTestImportTitle 2,TestTag2,""Hi ho"," said the circus manager. Don't
play the trumpet""

imported fine :-)

Thanks alot Eric :-))) My journey with TiddlyWiki can begin. Now I
will import the glossar I want included...

Best regards
Peter

Eric Shulman

unread,
Apr 24, 2009, 3:17:36 PM4/24/09
to TiddlyWiki
> find a documentation for the plugin and tried several options how a
> CSV file could look like. I assumed somthing like
>
> TiddlerTitleToImport,""Text to be imported, with a comma in the
> text"",tags separated by space

I've updated the tiddler (but not the version #) to include better
documentation about the necessary CSV formatting. Just click on the
'slider button' that reads "CSV-formatted data..." that appears in the
instruction text on the form itself.

enjoy,
-e

roger

unread,
Apr 24, 2009, 4:32:01 PM4/24/09
to TiddlyWiki
Eric, just wanted to add my thanks to you for updating the
CreateTiddlersFromCSV plugin to handle commas and double quotes. I
have a spreadsheet that contains data which I've been wanting to
leverage by putting the data into a TW. Some of that data contains
commas which really need to be preserved, so the improved
functionality you've added is just what I needed.

~Roger
Reply all
Reply to author
Forward
0 new messages