harmtemolder / wunderlist-to-evernote

A simple Python script that reformats a Wunderlist JSON export to an Evernote ENEX import
GNU General Public License v3.0
2 stars 1 forks source link

Doesn't work with new style Wunderlist exports #1

Open andriy-appuchino opened 4 years ago

andriy-appuchino commented 4 years ago
  1. I went to Wunderlist Account Settings
  2. And from there I was sent to https://export.wunderlist.com/export
  3. I received a zip file and used json file from it
  4. I got an error in Terminal:
    Traceback (most recent call last):
    File "wunderlist_to_evernote.py", line 7, in <module>
    from lxml import etree
    ImportError: No module named lxml
harmtemolder commented 4 years ago

Do you have lxml installed? If not, run this in your terminal:

pip install lxml

Did that solve your issue?

andriy-appuchino commented 4 years ago

Probably not. But today I successfully installed it this way:

brew install python
pip3 install lxml

But the result is the same.

harmtemolder commented 4 years ago

Ah, if you installed lxml for python3, then you might want to try running the script like so: python3 wunderlist_to_evernote.py wunderlist-xxx.json Did that work?

andriy-appuchino commented 4 years ago

Yeah almost..

Traceback (most recent call last):
  File "wunderlist_to_evernote.py", line 8, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

But I got how to make it work :)

andriy-appuchino commented 4 years ago

After installing pandas, it started, and I got such output:

wunderlist_to_evernote.py: Using Tasks.json as input
Traceback (most recent call last):
  File "wunderlist_to_evernote.py", line 149, in <module>
    wunderlist_to_evernote(input_file, output_file)
  File "wunderlist_to_evernote.py", line 14, in wunderlist_to_evernote
    wunderlist = json.load(wunderlist_raw)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 338, in loads
    s, 0)
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
harmtemolder commented 4 years ago

Hm, it looks like Wunderlist have changed the encoding of their exports. Could you try replacing lines 13 and 14:

with open(input_file) as wunderlist_raw:
  wunderlist = json.load(wunderlist_raw)

with: wunderlist = json.loads(open(input_file).read().decode('utf-8-sig'))

(Based on this)

andriy-appuchino commented 4 years ago

With wunderlist = json.loads(open(input_file).read().decode('utf-8-sig')) I got:

wunderlist_to_evernote.py: Using Tasks.json as input
Traceback (most recent call last):
  File "wunderlist_to_evernote.py", line 148, in <module>
    wunderlist_to_evernote(input_file, output_file)
  File "wunderlist_to_evernote.py", line 13, in wunderlist_to_evernote
    wunderlist = json.loads(open(input_file).read().decode('utf-8-sig'))
AttributeError: 'str' object has no attribute 'decode'

With wunderlist = json.load(codecs.open(input_file, 'r', 'utf-8-sig')) I got:

wunderlist_to_evernote.py: Using Tasks.json as input
Traceback (most recent call last):
  File "wunderlist_to_evernote.py", line 149, in <module>
    wunderlist_to_evernote(input_file, output_file)
  File "wunderlist_to_evernote.py", line 18, in wunderlist_to_evernote
    for list in wunderlist['data']['lists']:
TypeError: list indices must be integers or slices, not str
harmtemolder commented 4 years ago

I got Python to read the new style of exports using this:

    with open(input_file, encoding='utf-8-sig') as wunderlist_raw:
        wunderlist = json.load(wunderlist_raw)

Unfortunately they have also restructured the way the export is setup. There used to be separate arrays for tasks, subtasks and list names, but now it is an array of objects where each object is a list with everything else nested therein.

I hope this gives you enough to get started on rewriting my code to match the new export style. I don't actually use Wunderlist anymore, so have no need for this. If you are stuck somewhere in my code, I will of course give you some pointers on how to proceed.

Good luck

andriy-appuchino commented 4 years ago

I have never dealt with python, so if I can’t just use it by replacing some lines, then I won’t even try to rewrite your code, because I’ll be stuck there for a very long time. Thanks for the help.