i've run ledger using python,
but i still don't know what ledger's module to convert .csv to journal in
python
Could you give me some example to convert csv using pyhton?
what i've done so far, demo.py:
import MySQLdb
import csv
import os
import ledger
con = MySQLdb.connect("localhost", "root", "123123", "test")
cur = con.cursor()
query = "select * from transaction"
try:
cur.execute(query)
result = cur.fetchall()
fp = open("demo-data2.csv", "w")
file = csv.writer(fp)
header = ["transid", "date", "payee", "note", "amount", "", "", "code", ""]
file.writerow(header)
file.writerows(result)
fp.close()
except:
print("Error: Enable to connect database")
con.close()
os.system("ledger -f /dev/null convert demo-data2.csv --input-date-format
%m/%d/%Y -o demo-data2.dat")
os.system("ledger -f demo-data2.dat b -o demo-data2.txt")
On Wednesday, April 10, 2013 9:27:08 PM UTC+7, zdw wrote:
>
>
> On Wed, Apr 10, 2013 at 1:31 AM, <[email protected] <javascript:>>wrote:
>
>> Hello,
>> I want to convert .csv to .dat for generate repot with Python.
>>
>
> There are a lot (5+) of ways to convert CSV to ledger format via scripts.
>
>
>> Can python use ledger's module to convert and keep the report in python's
>> object?
>>
>
> As text? I think you need to walk the ledger object to get the data out.
>
> You might be better off running ledger from within the script and parsing
> it's output, depending on what you want.
>
> - Zack
>
>
>
>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.