mac_apt icon indicating copy to clipboard operation
mac_apt copied to clipboard

Notes plugin loses CR, LF, and tab when exporting to csv file

Open bshannon opened this issue 6 years ago • 2 comments

When exporting notes to a csv file, CR, LF, and tab are all replaced by a comma to avoid corrupting the format of the csv file. A better approach would be to convert these characters into some sequence that could be reversed later. For example, in plugins/helpers/writer.py, make this change:

--- a/plugins/helpers/writer.py
+++ b/plugins/helpers/writer.py
@@ -381,7 +381,7 @@ class CsvWriter:
         for item in row:
             safe_str = unicode(item)
             try:
-                safe_str = safe_str.replace('\r\n', ',').replace('\r', ',').replace('\n', ',').replace('\t', ' ')
+                safe_str = safe_str.replace('\\', '\\\\').replace('\r', '\\r').replace('\n', '\\n').replace('\t', '\\t')
             except Exception as ex:
                 log.exception()
             safe_list.append(safe_str)

For compatibility, you might want to introduce this change with a command line switch.

bshannon avatar Dec 11 '18 21:12 bshannon

Depending on your end usage, you may or may not want to do that. By performing string escapes, you make it less readable but more accurate to the original formatting. The csv output was not meant to be a perfect representation of the data, but rather a simple easy readable one, as well as importable into other tools (which may not understand string escapes).

Perhaps I can make this an option, with a command line switch. I will give it some thought.

ydkhatri avatar Dec 12 '18 03:12 ydkhatri

@bshannon I'm also needing to extract data from my Notes.app and was curious how that works with this package or what solution you came up with @bshannon.

@ydkhatri What is the process or code to access txt files or csv from Notes.app. I found a b brief explanation on your blog which is great BTW. https://www.swiftforensics.com/search?q=Notes is that post still valid?

datatalking avatar Dec 04 '22 02:12 datatalking