Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bshannon opened this issue Dec 11, 2018 · 2 comments
Open

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

bshannon opened this issue Dec 11, 2018 · 2 comments

Comments

@bshannon
Copy link

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.

@ydkhatri
Copy link
Owner

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.

@datatalking
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants