Quering for information inside a plugin data tiddler

I’ve imported a CSV into a data tiddler by using this handy guide. I now have the following structure:

  • A “plugin” tiddler containing all the data I’ve imported, call it Parent.

  • A list of shadow tiddlers inside Parent, call them Children. Each Child contains a row of the CSV’s values in its fields.

I’d like to create a Search tiddler that will contain a series of input fields (one for each of the Children’s fields) and a “Search” button that will return any matching data from inside the Parent tiddler.

I guess what I’m looking for is the most TiddlyWiki-style way of maintaining and querying a table of data :slight_smile:

1 Like

Usually plugins are expanded at startup to shadow tiddlers, which can be accessed directly with

[all[shadows+tiddlers]] which shows all shadow tiddlers and if some of them are overwritten it shows them too.

[is[shadow]] is the shortcut for [all[tiddlers]is[shadow]], which shows the overwritten shadow tiddlers.

So you should be able to directly access a list of all your “child tiddlers”. … The only info missing in your post is, how a “child” tiddler looks like.

If we would know it, we would be able to tell you how you can filter it. …

If it’s not possible to reveal your real structure, then you should give us an example and tell us how your “search results” should look like.

We may be able to point you in the right direction.

There are operators that can access shadow tiddlers. Look for widgets with the subtiddler parameter for some of these. I can share more when off my mobile but it is easy to include only tiddlers inside a specific plugins.

Consider allowing an edit of such shadow data tiddlers into tiddlers if you want to edit input data while keeping the original safe.

You’re right, an example would clarify things. Let me give you one.

  • The parent tiddler is called Data/Terminals
  • The shadow tiddler children inside the parent are named Data/Terminals/Terminal-nnn, where n goes sequentially from 0 to the low hundreds
  • Each Data/Terminals/Terminal-nnn has fields like:
    • Agent
    • Location
    • Service_ID
    • Terminal_ID

I’ve been thinking of having a form with the above fields and a button to perform the query, resulting in a table with the matching children. My use case is that I’ll be searching for terminals and copying their details to paste elsewhere.

Again, I’m thinking this in terms of how I’m already using this information as currently stored in a simple CSV file. I wanted to see how I could adjust my current workflow for use with TiddlyWiki. Maybe there’s a more TiddlyWiki-like way of solving the above need, if so I’d like to know about it.

Or, maybe it could be possible and/or preferable to keep the date in the CSV form and querying it directly as such, instead of importing/converting it as tiddlers?

I think, there should be no big problem to search in those fields.

I don’t have time atm to create some code, … I’ll have a look later today. … Maybe someone else is faster than me :wink:

@Lamnatos if you already know how to build tables from regular tiddlers, remember you are simply addressing shadow tiddlers.

eg; the filter “[all[shadows]prefix[Data/Terminals/Terminal-]]” is a start to access all your shadow data tiddlers. use “[all[shadows+tiddlers]prefix[Data/Terminals/Terminal-]]” to make use of overridden shadow tiddlers if they have being edited.

I think tiddlers is best because you can make use of all the normal filters and widgets where with CSV you will need to build much of the tools your self, hint splitregexp[\n] for new lines and split[,] for csv columns.

The following will help;
subtiddlerfields Operator
plugintiddlers Operator
Note the ViewWidget and TranscludeWidget have the subtiddlers parameter also to access subtiddlers in plugins.
shadowsource Operator

Tones

Try this:

Search: <$edit-text tiddler="temp/search" tag=input/>

<table><tbody>
<tr><th>Agent</th><th>Location</th><th>Service ID</th><th>Terminal ID</th></tr>
<$list filter="[all[shadows+tiddlers]prefix[Data/Terminals/]search:*{temp/search}]">
<tr><td>{{!!Agent}}</td><td>{{!!Location}}</td><td>{{!!Service-ID}}</td><td>{{!!Terminal-ID}}</td></tr>
</$list>
</tbody></table>
  • temp/search can be renamed to $:/temp/search so it will be a system tiddler and it will not be listed. But it’s easier for testing to use a standard tiddler.

  • [all[shadows+tiddlers] … lists all shadow tiddlers and all tiddlers

  • prefix[Data/Terminals/] … limits the output to tiddlers with your prefix

  • search:*{temp/search}] … search in all fields and use the content of temp/search tiddler as search string.

I’m attaching the tiddlers I did use to test it.

search-in-fields-table.json (1.1 KB)

Have fun!
Mario

It worked beautifully, thank you very much! I didn’t know of the search:* syntax to search across multiple fields, very handy.

Edit: It was an import option to import only the first 250 lines by default. I changed it and all of the data appeared:

In the end I found a possible bug with the handling of the raw CSV data, it looks like it truncates all data after around the 250th line (my data is 1,100 lines). If anyone’s interested, I’ve filed a bug at TW5-JsonMangler’s repo.