Re: Conversion nightmares: gnucash to ledger-cli

2017-06-09 Thread Rushad Faridi
Hello Richard,
Thanks a lot for your helpful suggestions and I am sorry for not getting 
back to you earlier. Actually the problem was that when I tried to convert 
gnucash files, I forgot to uncheck the compression option in GNU Cash 
software. That was a stupid mistake and it wasted me hours. Anyway, I got 
everything working after that and did not  require the python way anymore. 

Thanks again,
Rushad

On Wednesday, May 31, 2017 at 7:53:08 AM UTC+6, Rushad Faridi wrote:
>
> Hello all, I spent almost half of the day yesterday but could not get it 
> to work.   I wanted to convert my year old gnucash files to ledger and this 
> is what happened so far. 
>
> Firs I tried  ledger 2.x approach  since 3.x can not do the conversion.  I 
>  had not much of a problem installing 2.x  but after I issued the command " 
> ledger -f   myfile.gnucash  print > myfile.txt"  it spitted out 27 lines of 
> error with something " invalid date string".  I had a cursory look at my 
> account entries but did not find anything wrong. Any suggestions on how  to 
> fix that? 
>
> Anyway after failing in the first approach, I tried another. 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. Therefore, any help with the first approach (ledger 
> 2.x doing the converstion) or the 2nd approach (python conversion) will be 
> highly appreciated. 
>
>
> Rushad
> Dhaka, Bangladesh
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Conversion nightmares: gnucash to ledger-cli

2017-05-31 Thread Richard Lawrence
Dear Rushad,

Rushad Faridi  writes:

> Firs I tried  ledger 2.x approach  since 3.x can not do the conversion.  I 
>  had not much of a problem installing 2.x  but after I issued the command " 
> ledger -f   myfile.gnucash  print > myfile.txt"  it spitted out 27 lines of 
> error with something " invalid date string".  I had a cursory look at my 
> account entries but did not find anything wrong. Any suggestions on how  to 
> fix that? 

What were the errors that you saw?  Probably someone here can help you with 
this, but we'd need more information about what went wrong.

> 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

(It does not look like you should have "print" in this command line invocation, 
though probably the Python program is just ignoring it.)

> 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'

This is a strange error to see, if you are indeed using the code from that 
repository.  Python is complaining that it can't find the read_file function in 
the gnucash module.  But the gnucash module from that repository does contain 
such a function.  So either you're importing a *different* module named 
"gnucash", or something very weird is happening in the gnucash2ledger module 
that messes up the attributes of its own gnucash module.  I suspect the former.

Try this:

1) Run a Python interpreter from a directory *outside* the repository you 
referenced (so that the pygnucash code is not on Python's search path).

2) Type 'import gnucash' at the prompt.  You should see an ImportError.

3) If you do *not* see an ImportError, your Python is importing some other 
module named 'gnucash' (perhaps this comes with GnuCash itself?).  Try typing:

gnucash.__file__
gnucash.__path__

at the Python prompt.  This will tell you where the conflicting gnucash module 
is located. 

4) If you *do* see an ImportError, quit Python, and try these steps again, but 
this time run Python from *inside* the pygnucash repository.  This time, you 
should *not* see an ImportError.  In that case, make sure that gnucash.__file__ 
and gnucash.__path__ are what you'd expect, and then try

hasattr(gnucash, 'read_file')

This should return True.
 
Let us know what you see!

Best,
Richard

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.