Closed ksalman closed 6 years ago
I haven't tested gnucash 3 yet. Looks like they changed their format a bit. You can probably get it working by changing the strptime format string to '%Y-%m-%d %H:%M:%S'.
To fix it in a way that we can upstream here we would also need some way to differentiate between version 2 and version 3 files.
Actually, I did try changing this line https://github.com/MatzeB/pygnucash/blob/master/gnucash.py#L124 to
return datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
And now I see the following error
Traceback (most recent call last):
File "pygnucash/gnucash2ledger.py", line 34, in <module>
data = gnucash.read_file(sys.argv[1])
File "/Users/ksalman/beancount/pygnucash/gnucash.py", line 179, in read_file
return read_data(conn)
File "/Users/ksalman/pygnucash/gnucash.py", line 133, in read_data
trans.post_date = parse_time(post_date)
File "/Users/ksalman/pygnucash/gnucash.py", line 125, in parse_time
return datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
File "/usr/local/opt/pyenv/versions/3.6.5/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/local/opt/pyenv/versions/3.6.5/lib/python3.6/_strptime.py", line 362, in _strptime
(data_string, format))
ValueError: time data '20140603070000' does not match format '%Y-%m-%d %H:%M:%S'
Ok, I installed gnucash3 and looked at it. Should be fixed with af5971ccae62034356157088ccb421fd01d2c533
I feel like my change should've worked too, odd. Thank you for the speedy fix!
They don't change old records, so the code has to understand the old and the new format. Hence we couldn't just change the format but have to try both.
Oh I see, that makes sense. Thanks again.
I am trying to convert gnucash file. The file was originally written in gnucash 2.6 but I recently installed gnucash 3 and edited the file, so I am not sure if that makes a difference.
I am using Python 3.6.5 and I get this error