• tguillemin

    @cvp : I finally went for the iCloud solution, and, after copying the database in the Pythonista3 folder, inserted in my script :

    conn = sqlite3.connect('/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Hist.db')

    and it worked, albeit with a few preliminary quirks ("No such table", and later "No such column"…)

    Thank you very much for your help

    posted in Pythonista read more
  • tguillemin

    @cvp : Thanks again

    I finally succeeded. Sort of…

    I proceeded as indicated, was taken to my script, ran it and got the data I was looking for.
    But :

    a) this occurred in a light mode version of my script, although I have adopted the night mode in Pythonista

    b) when I tried to run the script by opening Pythonista as usual, I got an error ("argument 1 must be str, not None")

    c) I then tried something else : I imported the db file in my Pythonista SQLite folder. But when I tried to retrieve data in it, came an error "there is no such table as data", although this table had been acknowledged in the attempt a)

    It seems I do not grok the process. Furthermore I do not understand why it is impossible to establish a permanent link between a Pythonista script and a file in Dropbox.
    Would it be different in iCloud Drive ?

    posted in Pythonista read more
  • tguillemin

    @cvp : First of all, thank you for your answer. But I seem to be doing it all wrong…

    1. in my Pythonista script "SQLiteHist.py" (it is a simple tool for a chronology database), I added : import appex. I understand I shall have to insert a appex.get_file_path() line in my script

    2. Then I went to my Files app/Dropbox (btw I am on iPhone 7 plus) :

    • I selected the Hist.db (the aforementioned chronology database)

    • I pressed until appeared the menu (Copy…Duplicate…etc…Share)

    • I then selected Share, which brought me to the Share Menu…

    • …where I selected Run Pythonista script

    • I did not have the possibility to choose my SQLiteHist.py script : the process started downloading the file (endlessy), and I canceled it

    • To sum it up I could not select my script, thus it did not receive any link to my db file

    Sorry to be so awkwardly precise.

    Where did I go wrong ?

    posted in Pythonista read more
  • tguillemin

    I have created a sqlite script in Pythonista, and I wish to insert/update/append/delete/retrieve data stocked in an existing .db file which is in my Dropbox account.

    If I try to use the EXTERNAL FILES/Open…, I can see my file, but I am unable to open it.

    So, for the time being, I am obliged to re-create that file inside Pythonista…

    How should I proceed ?
    And if it is possible what path should I indicate ? I tried :

    conn = sqlite3.connect('Dropbox/somefile.db')

    and, of course, it did not work ("unable to open database file").

    Thanks in advance```

    posted in Pythonista read more
  • tguillemin

    In order to have a river-style (Dave Winer) feed about book reviews in some great newspapers (NYT, The Economist, Le Monde, Japan Times), I created a RSSMix feed of the 4 and "borrowed" a script from : [http://www.idiotinside.com/2017/06/08/parse-rss-feed-with-python/](Parse RSS feed with Python)

    Here is the script :

    # coding: utf-8
    import os
    import sys
    import feedparser
    import console
    #source : http://www.idiotinside.com/2017/06/08/parse-rss-feed-with-python/
    feed = feedparser.parse("http://www.rssmix.com/u/8265752/rss.xml")
    # RSSmix of Books reviews from : NYT, TE, LM, JT
    feed_title = feed['feed']['title']
    feed_entries = feed.entries
    for entry in feed.entries:
        article_title = entry.title
        article_link = entry.link
        article_published_at = entry.published # Unicode string
        article_published_at_parsed = entry.published_parsed # Time object
        article_description = entry.description
        article_summary = entry.summary
        #article_tags = entry.tags.label    <--------- PB
        print ("{}".format(article_title))
        print ("{}".format(article_published_at))
        print ("{}".format(article_link))
        print ("{}".format(article_summary))
        #print ("{}".format(article_tags))   <--------- PB
        print (" ")
        print ("....................")
        print (" ")
    file_name = os.path.basename(sys.argv[0])

    All in all, it works.
    I nevertheless encounter a few problems :

    • I would like to position the page at the most recent feed (top of the output), whereas the script positions it at the bottom
    • I cannot figure out how to grab the entries' tags which would allow me to "filter" some entries
    • It seems that the output keeps on growing… How do I eliminate entries e.g. older than 30 days ?

    Thanks in advance for your help.

    posted in Pythonista read more
  • tguillemin

    @dgelessus : Thank you for your answer. which is what I had (approximately) figured.

    How is it possible to make to @olemoritz the suggestion/request/wish to "unleash" the power of regex in that specific action (and elsewhere, of course, if needed) ?

    This would make the irreplaceable Editorial even better.

    Thanks again

    posted in Editorial read more
  • tguillemin

    BTW, I also tried this simpler solution :


    which also works in Regex101, but, alas, not in the "Fold Lines Containing" action…

    posted in Editorial read more
  • tguillemin

    Do you mean \\n ?


    I tried it, but it does not work.

    Thank you anyway

    posted in Editorial read more
  • tguillemin

    I have the following text :

    This is paragraph #1   
    [comment]: # (London, Paris)   
    This is paragraph #2   
    [comment]: # (Paris, Berlin)   
    This is paragraph #3   
    [comment]: # (London, Berlin)   
    This is paragraph #4 
    [comment]: # (Paris)
    This   is paragraph #5   
    [comment]: # (Berlin)

    I want to match all the lines containing Berlin AND for each match, the line before, in order to fold all the lines NOT containing this pattern :

    This is paragraph #2   
    [comment]: # (Paris, Berlin)   
    This is paragraph #3   
    [comment]: # (London, Berlin)   
    This   is paragraph #5   
    [comment]: # (Berlin)

    I came up with this solution

    which works under Python in Regex101 and which you can find at 
    [https://regex101.com/r/jXD7gw/3](link url)
    But when I try it in Editorial, it fails (simple workflow with FOLD LINES CONTAINING… with that regex and, of course the INVERT button on.
    Where did I go wrong ?
    Thanks in advance

    posted in Editorial read more
  • tguillemin


    I have the feeling, after using your VERY useful workflow, that we answer 2 different cases :

    • my solution : if the contents of a fold contain a specific pattern (and there can be as many different patterns as there are different words in the text), then keep open (unfolded) the fold with its contents
    • your solution : if a pattern is found, and this pattern is bound to be more specific (@something, or as I tried #\d{3}, etc...), keep the fold unfolded with its contents wether the pattern is found in the header or found in the contents of the fold

    My conclusion - and I am very grateful for your answer - is that these 2 solutions are complementary, for my specific uses anyway.

    Thanks again for your help

    posted in Editorial read more

Internal error.

Oops! Looks like something went wrong!