mac_apt
mac_apt copied to clipboard
Notes plugin loses CR, LF, and tab when exporting to csv file
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.
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.
@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?