matzeb / pygnucash Goto Github PK
View Code? Open in Web Editor NEWPython code to read gnucash 2.6 sqlite3 files; features gnucash 2 ledger translator.
License: BSD 2-Clause "Simplified" License
Python code to read gnucash 2.6 sqlite3 files; features gnucash 2 ledger translator.
License: BSD 2-Clause "Simplified" License
It doensn't work on python 3.
Gnucash exported the transactions using UTC time, while the Gnucash software is set to UTC+2.
Therefore transactions that occured on "2016/08/02" were exported as "2016/08/01 22:00" and interpreted as "2016/08/01".
I used this hack in gnucash.py
to adjust:
import calendar
# ...
def parse_time(time):
dt = datetime.strptime(time, "%Y%m%d%H%M%S")
timestamp = calendar.timegm(dt.timetuple()) + 7200
return datetime.utcfromtimestamp(timestamp)
Maybe this could be made configurable using a CLI switch?
Ran 'gnucash2ledger.py' as:
python gnucash2ledger.py example.gnucash
It spat out:
Traceback (most recent call last):
File "gnucash2ledger.py", line 10, in <module>
data = gnucash.read_file(sys.argv[1])
File "/home/scott/bin/pygnucash/gnucash.py", line 78, in read_file
for row in c.execute('SELECT guid, namespace, mnemonic, fullname FROM commodities'):
sqlite3.DatabaseError: file is encrypted or is not a database
Python 2.7.3
Sqlite 3.7.9
Gnucash 2.6.3
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
Traceback (most recent call last):
File "pygnucash/gnucash2ledger.py", line 34, in <module>
data = gnucash.read_file(sys.argv[1])
File "/Users/ksalman/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 124, 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 '2017-11-06 10:59:00' does not match format '%Y%m%d%H%M%S'
I'm finding that transactions with extra import info are being silently dropped by gnucash2ledger.py
.
An example of such a transaction would currently be output by Piecash's piecash_ledger.py
like this...
2014/01/01 * WITHDRAWAL AT HANDYBANK MELB CTL 5 O/S 25420178 01/01/14
;OFX ext. info: |Trans type:Cash withdrawal
Assets:Current:Westpac SAV -180.00 AUD ; WITHDRAWAL AT HANDYBANK MELB CTL 5 O/S 25420178 01/01/14
Expenses:Unspecified:AUD 180.00 AUD
(Which is also not quite right, because it causes errors with ledger... I opened an issue for that on sdementen/piecash
).
Hi; I'm trying to run gnucash2ledger.py in Python3, already typed import gnucash, I'm getting this error:
Traceback (most recent call last):
File "gnucash2ledger.py", line 34, in
data = gnucash.read_file(sys.argv[1])
AttributeError: module 'gnucash' has no attribute 'read_file'
how should I proceed? Help me plz
Thanks in advance.
I don't know if it's compatible with python2 or python3.
Solution : Document which version of python pygnucash is compatible with.
Gnucash has the option (by default) to save files as xml. I've created a script that reads these files (compressed or uncompressed) and outputs a file in ledger file format:
Here's the link in case anyone is interested:
https://github.com/lodenrogue/gnucash2ledger
Also listed on the official hledger gnucash page:
https://hledger.org/gnucash.html
I compiled latest gnucash (2.6.16) from source with dbi conversion enabled. From gnucash I could save as sqlite3 but the files were saved as "myfile.gnucash" not "myfile.sqlite3". But I don't know whether it will have sqlite3 extension in the first place when saved. Anyway, I went ahead and ran the python script "gnucash2ledger.py" downloaded from "https://github.com/MatzeB/pygnucash" in the following manner:
python2.7 gnucash2ledger.py myfile.gnucash print > test.txt
The error came through is as follows:
Traceback (most recent call last):
File "gnucash2ledger.py", line 35, in
data = gnucash.read_file(sys.argv[1])
AttributeError: 'module' object has no attribute 'read_file'
I noticed in the script page that it says that it requires python 2.7 with sqlite3 module enabled. After some search I did the following to enable sqlite3:
sudo apt-get install sqlite3 libsqlite3-dev
sudo pip install pysqlite
But no luck so far.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.