[tw5] Re: Importing a tiddler written with python?

2020-08-30 Thread amreus
Just a suggestion: I wouldn't build the json string manually. I would use a 
python dict and add the key/value pairs, then let the JSON library 
serialize it as a json string. 

It's the same idea I use only in Ruby for converting my gedcom files to 
tiddlers.


On Thursday, August 27, 2020 at 4:24:38 PM UTC-4, Jimmy Sweeney wrote:
>
> Hi there,
>
> Would anyone have any clues why this file 
> 
>  
> isn't importing nice and cleanly into my TiddlyWiki? It imports but not 
> nice and clean like dragging and dropping a tiddler from another TiddlyWiki 
> site does.
>
> I'm trying to create a python script that creates tiddler files. I input 
> the ISBN (a book ID number essentially) and spits out a tiddler file with 
> the title, author, cover image, etc.
>
> Anyway, I based my format on the format of a Tiddler 
>  that I 
> exported from tiddlywiki.com .
>
> What magic ingredients am I missing?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/36f1e0ce-e14f-4e5f-a53a-1c20141a02a4o%40googlegroups.com.


Re: [tw5] Re: Importing a tiddler written with python?

2020-08-28 Thread Jimmy Sweeney
Thanks Mark! Adding those things to my TODO.

This is literally my first ever program that I wrote on my own. So this
little script is the equivalent of that first wobbly table that a kid makes
in woodworking. I’m just happy that it works!

I actually noticed that there are some not-so-obscure ISBNs that meta can’t
find. But there are some other tools in isbnlib for finding books so I’ll
look into that as well.

A little background on why I made this. I have a list of books read/to read
on Goodreads that I wanted to import easily into my TiddlyWiki. I also have
an xml file of exported posts from Wordpress that I’d like to import to my
TW. Now that I know it’s possible I’ll get working on a script that can do
that next (unless someone knows of something that can already do that).

On Fri, Aug 28, 2020 at 11:29 AM 'Mark S.' via TiddlyWiki <
tiddlywiki@googlegroups.com> wrote:

>
>
> Nice Work!
>
> It's been a long time since using Python, but it was one of my favorite
> languages.
>
> Comments
>
> Since python has a library for everything, I'm thinking they must have a
> library for JSON. This way you don't have to build your own strings, which
> is subject to error (as you discovered). Just a thought.
>
> I don't see any error handling. What happens if someone mis-types an ISBN
> number? Or if "meta" can't find a number (I was just looking for an obscure
> ISBN yesterday -- it wasn't on Amazon).
>
> It appears you're hard-coding {{!!title}} etc. into the text field. That
> means if you want to change the appearance you will have to go back to
> every single tiddler and change it. You might want to consider using
> tiddlywiki templates instead.
>
> https://tiddlywiki.com/#TemplateTiddlers
>
> Have fun!
>
>
>
>
> On Friday, August 28, 2020 at 8:04:01 AM UTC-7, Jimmy Sweeney wrote:
>>
>> Thanks all! I figured it out!
>>
>> Mark - you were correct. I needed to get rid of any line breaks so that
>> the resulting file was all just one line.
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "TiddlyWiki" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/tiddlywiki/VCn3kDOmTD4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> tiddlywiki+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/32525d9f-6dd5-4aab-9202-35126a06f125o%40googlegroups.com
> 
> .
>
-- 
Sent from Gmail Mobile

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAC8Gt88J%2B3DiS6-9Nm-mjR-L57AzywUxivq-eVOgPB%2BX6KgDfQ%40mail.gmail.com.


Re: [tw5] Re: Importing a tiddler written with python?

2020-08-28 Thread 'Mark S.' via TiddlyWiki


Nice Work!

It's been a long time since using Python, but it was one of my favorite 
languages.

Comments

Since python has a library for everything, I'm thinking they must have a 
library for JSON. This way you don't have to build your own strings, which 
is subject to error (as you discovered). Just a thought.

I don't see any error handling. What happens if someone mis-types an ISBN 
number? Or if "meta" can't find a number (I was just looking for an obscure 
ISBN yesterday -- it wasn't on Amazon).

It appears you're hard-coding {{!!title}} etc. into the text field. That 
means if you want to change the appearance you will have to go back to 
every single tiddler and change it. You might want to consider using 
tiddlywiki templates instead. 

https://tiddlywiki.com/#TemplateTiddlers

Have fun!




On Friday, August 28, 2020 at 8:04:01 AM UTC-7, Jimmy Sweeney wrote:
>
> Thanks all! I figured it out! 
>
> Mark - you were correct. I needed to get rid of any line breaks so that 
> the resulting file was all just one line.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/32525d9f-6dd5-4aab-9202-35126a06f125o%40googlegroups.com.


Re: [tw5] Re: Importing a tiddler written with python?

2020-08-28 Thread Jimmy Sweeney
Thanks all! I figured it out!

Mark - you were correct. I needed to get rid of any line breaks so that the
resulting file was all just one line.

If anyone else wants to use my program, here it is:
https://github.com/sweenejp/files/blob/master/isbn_to_json_for_tiddlywiki.py
and
an example of an output file here:
https://github.com/sweenejp/files/blob/master/Cosmos.json

Sorry the python code is a little messy (I'm very much a beginner at
coding). I made everything a field and then had certain fields transcluded
into the text field. You can change the fields to whatever you want (for
instance the "tags" field).

Pretty cool to know that TiddlyWiki files are basically like Python
dictionaries. Now that I say that, I'm sure there would have been a much
cleaner way to write my code. I could have just created a dictionary based
on the keys and values that a Tiddler requires. Oh well.

Thanks for all the help!

On Thu, Aug 27, 2020 at 5:51 PM TW Tones  wrote:

> FYI: Someone has already done an ISBN tiddler, Not sure where, sorry.
>
> Tones
>
> On Friday, 28 August 2020 06:24:38 UTC+10, Jimmy Sweeney wrote:
>>
>> Hi there,
>>
>> Would anyone have any clues why this file
>> 
>> isn't importing nice and cleanly into my TiddlyWiki? It imports but not
>> nice and clean like dragging and dropping a tiddler from another TiddlyWiki
>> site does.
>>
>> I'm trying to create a python script that creates tiddler files. I input
>> the ISBN (a book ID number essentially) and spits out a tiddler file with
>> the title, author, cover image, etc.
>>
>> Anyway, I based my format on the format of a Tiddler
>>  that I
>> exported from tiddlywiki.com .
>>
>> What magic ingredients am I missing?
>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "TiddlyWiki" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/tiddlywiki/VCn3kDOmTD4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> tiddlywiki+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/fca6251b-d5ad-4657-9f94-bcd7332c8a52o%40googlegroups.com
> 
> .
>


-- 
414 5540826

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAC8Gt8_QvJMD80gNmVhQyTTamkpqp3msubLYUQM1wqJG_z8vyQ%40mail.gmail.com.


[tw5] Re: Importing a tiddler written with python?

2020-08-27 Thread TW Tones
FYI: Someone has already done an ISBN tiddler, Not sure where, sorry.

Tones

On Friday, 28 August 2020 06:24:38 UTC+10, Jimmy Sweeney wrote:
>
> Hi there,
>
> Would anyone have any clues why this file 
> 
>  
> isn't importing nice and cleanly into my TiddlyWiki? It imports but not 
> nice and clean like dragging and dropping a tiddler from another TiddlyWiki 
> site does.
>
> I'm trying to create a python script that creates tiddler files. I input 
> the ISBN (a book ID number essentially) and spits out a tiddler file with 
> the title, author, cover image, etc.
>
> Anyway, I based my format on the format of a Tiddler 
>  that I 
> exported from tiddlywiki.com .
>
> What magic ingredients am I missing?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fca6251b-d5ad-4657-9f94-bcd7332c8a52o%40googlegroups.com.


Re: [tw5] Re: Importing a tiddler written with python?

2020-08-27 Thread 'Mark S.' via TiddlyWiki


On Thursday, August 27, 2020 at 2:24:59 PM UTC-7, Jimmy Sweeney wrote:
>
> Hi Saq - why would that be? When I export other tiddlers as json files 
> they have line breaks as "\n". 
>
>
I don't think they have line breaks in the middle of text strings, as yours 
does. Wherever there was a line break, there needs to be a \n instead.

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/db77ea8c-d906-442a-b918-63028e9496a9o%40googlegroups.com.


Re: [tw5] Re: Importing a tiddler written with python?

2020-08-27 Thread dieg...@gmail.com
Hi,

When I take that raw string, save it as a .json file and upload that to 
tiddlywiki.com I can see the imported tiddler just fine! 

On Thursday, August 27, 2020 at 4:24:59 PM UTC-5 swee...@gmail.com wrote:

> Hi Saq - why would that be? When I export other tiddlers as json files 
> they have line breaks as "\n". 
>
> Thanks Eric, I fixed those two things but still no luck. 
> 
>
> On Thu, Aug 27, 2020 at 3:47 PM Saq Imtiaz  wrote:
>
>> Make sure the text field in the JSON does not contain linebreaks or other 
>> characters that need to be escaped.
>>
>> On Thursday, August 27, 2020 at 10:24:38 PM UTC+2 swee...@gmail.com 
>> wrote:
>>
>>> Hi there,
>>>
>>> Would anyone have any clues why this file 
>>> 
>>>  
>>> isn't importing nice and cleanly into my TiddlyWiki? It imports but not 
>>> nice and clean like dragging and dropping a tiddler from another TiddlyWiki 
>>> site does.
>>>
>>> I'm trying to create a python script that creates tiddler files. I input 
>>> the ISBN (a book ID number essentially) and spits out a tiddler file with 
>>> the title, author, cover image, etc.
>>>
>>> Anyway, I based my format on the format of a Tiddler 
>>>  that I 
>>> exported from tiddlywiki.com .
>>>
>>> What magic ingredients am I missing?
>>>
>>>
>>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "TiddlyWiki" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/tiddlywiki/VCn3kDOmTD4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> tiddlywiki+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/50f4ba7a-2c94-41a2-a87d-2185aaf8fe30n%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> 414 5540826 <(414)%20554-0826>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/00ba9500-5062-439a-b78f-7e96f9926578n%40googlegroups.com.


Re: [tw5] Re: Importing a tiddler written with python?

2020-08-27 Thread Jimmy Sweeney
Hi Saq - why would that be? When I export other tiddlers as json files they
have line breaks as "\n".

Thanks Eric, I fixed those two things but still no luck.


On Thu, Aug 27, 2020 at 3:47 PM Saq Imtiaz  wrote:

> Make sure the text field in the JSON does not contain linebreaks or other
> characters that need to be escaped.
>
> On Thursday, August 27, 2020 at 10:24:38 PM UTC+2 swee...@gmail.com wrote:
>
>> Hi there,
>>
>> Would anyone have any clues why this file
>> 
>> isn't importing nice and cleanly into my TiddlyWiki? It imports but not
>> nice and clean like dragging and dropping a tiddler from another TiddlyWiki
>> site does.
>>
>> I'm trying to create a python script that creates tiddler files. I input
>> the ISBN (a book ID number essentially) and spits out a tiddler file with
>> the title, author, cover image, etc.
>>
>> Anyway, I based my format on the format of a Tiddler
>>  that I
>> exported from tiddlywiki.com .
>>
>> What magic ingredients am I missing?
>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "TiddlyWiki" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/tiddlywiki/VCn3kDOmTD4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> tiddlywiki+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/50f4ba7a-2c94-41a2-a87d-2185aaf8fe30n%40googlegroups.com
> 
> .
>


-- 
414 5540826

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAC8Gt89nTMbpsAxhJ9U13SfELtScCkBEpzAYWQdfBiahjToL0A%40mail.gmail.com.


[tw5] Re: Importing a tiddler written with python?

2020-08-27 Thread Saq Imtiaz
Make sure the text field in the JSON does not contain linebreaks or other 
characters that need to be escaped.

On Thursday, August 27, 2020 at 10:24:38 PM UTC+2 swee...@gmail.com wrote:

> Hi there,
>
> Would anyone have any clues why this file 
> 
>  
> isn't importing nice and cleanly into my TiddlyWiki? It imports but not 
> nice and clean like dragging and dropping a tiddler from another TiddlyWiki 
> site does.
>
> I'm trying to create a python script that creates tiddler files. I input 
> the ISBN (a book ID number essentially) and spits out a tiddler file with 
> the title, author, cover image, etc.
>
> Anyway, I based my format on the format of a Tiddler 
>  that I 
> exported from tiddlywiki.com .
>
> What magic ingredients am I missing?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/50f4ba7a-2c94-41a2-a87d-2185aaf8fe30n%40googlegroups.com.


[tw5] Re: Importing a tiddler written with python?

2020-08-27 Thread Eric Shulman
On Thursday, August 27, 2020 at 1:24:38 PM UTC-7, Jimmy Sweeney wrote:
>
> Would anyone have any clues why this file 
> 
>  
> isn't importing nice and cleanly into my TiddlyWiki? It imports but not 
> nice and clean like dragging and dropping a tiddler from another TiddlyWiki 
> site does.
>

The first thing I noticed is that the "created" field is not the correct 
format.

It's supposed to be a 17-digit value, MMDDhhmmssXXX, where:
*  is the year number
* MM is the month number
* DD is the date 
* hh is the hours
* mm is the minutes
* ss is the seconds
* XXX is the milliseconds
(note that all values are zero-padded as needed)

The second thing I notice is that there is no "modified" field.
Without this field, the tiddler won't appear in the "recent" sidebar tab 
list.

Hope this helps...

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e23545ba-7039-4a82-b98d-20c7e21bc997o%40googlegroups.com.