code to parse exported decrypted text file for tags #2692
Replies: 9 comments
-
Probably the best place to look is at our single page offline decryption script, which decrypts and parses the SN relational text file: https://github.com/standardfile/decrypt/blob/master/decrypt.html |
Beta Was this translation helpful? Give feedback.
-
Here is the code I wrote and tested on my exported data. It inputs the exported JSON file, modifies the JSON to add tags to each note, and outputs the modified JSON to a new file. It also writes a set of separate files, one for each note, in a specified directory. The code is written in the matlab language but it should also run on the free, open source, octave program although I haven't tested that. I use the JSONlab code that is available on the matlab file exchange. The functions of this package can decode JSON files into matlab data structures and also encode a matlab data structures into a JSON file. The first section of my code uses the loadjson function from the package to read the standard notes exported Jason file. The result is a cell array of data structures, the 'items' array, with one cell for each item in the user's standard notes data. A cell is a matlab container that can hold any matlab object. In our case, each cell contains a struct, which is a matlab structure with named fields can hold matlab objects. The fields for the standard notes data are all text strings. -------------------------------- code ---------
See the next response for a continued discussion. |
Beta Was this translation helpful? Give feedback.
-
There are different kinds of items in the 'items' array. Of interest to us are the notes and the tag items. The next section of code scans through the array to find the indexes of the notes items 'idx2Notes' and the tag items 'idx2Tags'. The code also extracts a cell array of the unique ids of all the items, 'uuids'. It turns out that the array also includes trashed notes, so it identifies those thru 'idx2Trashed' although we don't use them in the rest of the code. ------code-----------
continued in next comment |
Beta Was this translation helpful? Give feedback.
-
The next section of code goes through all the tag items. For each tag item it uses the references member, which contains the unique IDs of all the notes with that tag. It searches the uuids array to find the index of the pointed-to note. It modifies the item's content member to add a tags field if none exists or to append the tag name, which is the title of the tag, to the field.
|
Beta Was this translation helpful? Give feedback.
-
Next the code uses the savejson function from the JSONlab package to save the modified items array to a new file. -------code-------------
|
Beta Was this translation helpful? Give feedback.
-
Finally, the code saves the notes as taxt files in a specified directory. The names of the files are the note titles so there are several regular expression replaces to make the title into a legal file name. I intend to modify the code to output a file that can be input to InfoSelect, which I have used for many years as my desktop computer personal information manager. --------code----------
|
Beta Was this translation helpful? Give feedback.
-
The code calls the WriteStdNote function to acually write out the note text:
|
Beta Was this translation helpful? Give feedback.
-
Very cool! Not familiar with matlab but is it possible to create a reusable package from the code above? |
Beta Was this translation helpful? Give feedback.
-
Thanks. See the first comment. If there is any interest in a reusable package, I will look into converting to a standalone program or other application. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
edit: I wrote Matlab code to process the exported JSON file and write the notes to separate files for each tag. The code is in my GitHub repository https://github.com/4bob1/process-standardnotes-archive. If you are interested in modifying the code for other functions, leave a comment on this thread
In issue #366 (open), Caldefredo asked "Is there a way to save the tags within the exported/backup text files?"
Mobitar answered: "The relational text file is just simple JSON, so you could parse that if you wanted to. But otherwise, individual text notes in the zip folder do not contain anything but note contents."
Before I start writing code, can anyone provide the code to parse the relational decrypted text file and output individual text notes that include the note's tags? If so, please provide a link to the code or include it in your answer.
Thanks in advance.
Bob
Beta Was this translation helpful? Give feedback.
All reactions