Jump to content

Search question: get range of text from a note?


Recommended Posts

Among other uses, I keep a daily journal in Evernote and in it I keep track of various "personal data mining" details: sleep times, if I got exercise, mood, etc. and I would like to be able to extract this data to dump into a graphing program like Excel or Numbers (I'm on OSX). I've been reading up on Evernote's support for Applescript and it looks pretty deep, as does the Evernote query syntax. It seems like if I had a dedicated notebook with a standardized format for entering my data, I would be able to extract and parse it in AppleScript and then dump it out to a file or to one of the programs mentioned.

Where it gets tricky is that I don't want to have this data in a notebook separate from my journal – I want in on the page for each day. I have a little table that I paste into each new note (not up to speed with templates yet)

Mood:     8     [range 1-10]
Sleep:    7.5   [float]
Exercise: 1     [Bool]
Social:   1     [Bool]
etc.

My question: since a table is not a named object that I can just reference and grab the content of, I figure I need to define  #start and #end tags of some sort and then grab everything in between them, and then pass that string to AppleScript to extract the data into some key-value date structure. I can handle the AppleScript side of this but I don't know if Evernote will let me target a range of text like that. I guess I could grab all the text but my journal entries are rather verbose (like my post here... ? )  so it wouldn't be very efficient.


Anyone done anything like this with searching? Is it possible?

Thanks! ?

Link to comment
  • Level 5*
1 hour ago, dataDiva said:

I figure I need to define  #start and #end tags of some sort and then grab everything in between them, and then pass that string to AppleScript to extract the data into some key-value date structure. I can handle the AppleScript side of this but I don't know if Evernote will let me target a range of text like that. I guess I could grab all the text but my journal entries are rather verbose (like my post here... ? )  so it wouldn't be very efficient.

Yes, it can be done

My Applescript project is documented here where I actually used the html tags to extract text, but #start and #end tags would work just as well

The code is
set AppleScript's text item delimiters to {"href=\""}
set
parsedList to text items of noteHTML

 

 

Link to comment

@DTLow  – thanks very much for the example. Helps a lot.

I need to sort out my data structure to make it easier to parse. I tried using div ids and table ids but the ids get stripped out . Logging the myTable var below shows the id intact but when I log the HTML content of a note in which I've appended a table, it isn't there. Curiously, div id  for the enclosing div of the note is there ("<div id="en-note">").

Going to have to tinker more. Funny, it's "Back to the Future" – so rarely do I work with AppleScript. Takes me back the Hypercard and Macromedia Director's Lingo, right down to commented out lines with "--" rather than "//". Hilarious.

set myTable to "<table id=\"bunny\">"
append CurrentNote html myTable
  
  
set newText to "<div id=\"fish\">What's for dinner</div>"
append CurrentNote html newText

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...