• tguillemin

    First of all, thank you very much for your answer.

    Three remarks

    1. I am a Python newbie… How do I insert this in a workflow ? Through "RunPython script", I suppose (coming after an "Extend Selection" to the whole document ?), but how ?

    2. How come a sequence \b\n\b in Find and a space in Replace does not work, although it works perfectly well in Regex101 ?
      Could it be a bug ? I doubt it. I most certainly make a mistake, but where ?

    3. I do not (entirely) share your condemnation of Regexes, but, as you know, nobody is perfect…

    Thanks again

    posted in Editorial read more
  • tguillemin

    I have the following text :

    Paragraph1
    
    Paragraph2
    Paragraph2
    Paragraph2
    Paragraph2
    
    Paragraph3
    Paragraph3
    
    Paragraph4```
    

    I want to merge the lines of each paragraph, in order to get :

    Paragraph1
    
    Paragraph2 Paragraph2 Paragraph2 Paragraph2
    
    Paragraph3 Paragraph3
    
    Paragraph4 
    

    Thanks to Stackoverflow, I found a solution which passes the Regex101 test

    But I cannot make it work in Editorial's Find/Replace (and I did not forget to choose Regular Expression…)

    What do I get wrong ?

    posted in Editorial read more
  • tguillemin

    Thank you very much for your answer and, may I add, thank you very much for this indispensable app (together with Pythonista, of course…)

    posted in Editorial read more
  • tguillemin

    I have the following text :

    Paris Rome
    London Berlin
    London Rome
    Paris Berlin Berlin
    Rome London
    Berlin Madrid
    paris Madrid

    I wish to count the number of lines containing London (3 lines)

    I run the following workflow

    [http://www.editorial-workflows.com/workflow/5858062694875136/Sy1_sF8-Vbs](link url)

    which gives me the answer "The word London occurs in 0 lines" (but the highlighting on the contrary is correct)

    The explanation is most certainly evident, but I cannot find it…

    Where did I go wrong ?

    Thanks in advance

    posted in Editorial read more
  • 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/
    
    feedparser._HTMLSanitizer.acceptable_elements.update(['iframe'])
    
    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
        
        console.set_color(0,1,0)
        print ("{}".format(article_title))
        console.set_color(1,1,1)
        print ("{}".format(article_published_at))
        console.set_color(0,0.75,1)
        print ("{}".format(article_link))
        console.set_color(1,1,1)
        print ("{}".format(article_summary))
        #print ("{}".format(article_tags))   <--------- PB
        print (" ")
        print ("....................")
        print (" ")
        
    file_name = os.path.basename(sys.argv[0])
    print(file_name)
    

    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

Internal error.

Oops! Looks like something went wrong!