GnuCash statistics
Cristian Marchi
cri79 at libero.it
Sun Dec 2 09:25:14 EST 2012
Bob, your script worked great! thank you very much!
I've now a script that downloads a json file for each release of GnuCash
in the 2.4 series with data from 2010-11-01 to 2012-11-30. It is like this:
for i in {0..11}; do wget
"http://sourceforge.net/projects/gnucash/files/gnucash%20%28stable%29/2.4.$i/stats/json?start_date=2010-11-01&end_date=2012-11-30"
-O gnucash2.4.$i.json; done
I can then convert each json file to a csv file with your script so that
I can copy-paste data in a single spreadsheet to generate the graph.
In order to make the process more automatic, would it be possible to
create a csv file with only ["downloads"] data ordered as shown in the
attached downloads.csv file?
Regards
Cristian
Il 02/12/2012 02:35, Bob Hossley ha scritto:
> On 2012-11-30 13:16, Cristian Marchi wrote:
>> I would like to create some graphs about GnuCash downloads. I noticed
>> that sourceforge makes available the data for every file in json format
>> [1].
>> What I would like to do is to create a script that download all the
>> files for the GnuCash 2.4 releases (11 files as of now), reads the
>> downloads number associated to a month, and create a formatted file
>> (rows of downloads and date) to be imported in calc. I looked for a way
>> to do this but I had no luck. Can someone with a better experience with
>> json files give me a hint on how to do that?
>>
>> Thanks for any help!
>>
>> [1]
>> http://sourceforge.net/projects/gnucash/files/gnucash%20%28stable%29/2.4.11/stats/json?start_date=2010-11-01&end_date=2012-11-30
>>
>> _______________________________________________
>> gnucash-devel mailing list
>> gnucash-devel at gnucash.org
>> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>>
> Cristian,
>
> I'm not sure what information in what format you want, but the attached
> will allow you to import ALL the information into LibreOffice Calc.
>
> usage: stats01.py [options] jsonPath csvPath
>
> GnuCash Stats for Cristian Marchi
>
> positional arguments:
> jsonPath Pathname of json file containing stats.
> csvPath Pathname of csv file to create
>
> optional arguments:
> -h, --help show this help message and exit
>
> I made the stats1-raw.json by looking at the stats page using Firefox,
> Ctrl-A to select all the data. Opening an editor and pasting all the
> data, and then writing stats1-raw.json.
>
> I made stats1-pretty.json with this script:
>
> #!/usr/bin/python
> # -*- coding: utf-8 -*-
>
> import codecs
> import os
> import json
> import sys
>
> fiPaName = sys.argv[1]
> handle = codecs.open(fiPaName, 'r', encoding='utf-8')
> oft = json.load(handle)
> handle.close()
> os.rename(fiPaName, fiPaName + '.bak')
> handle = codecs.open(fiPaName, 'w', encoding='utf-8')
> handle.write(json.dumps(oft, sort_keys=True, indent=4))
> handle.close()
>
> stats1-pretty.json is human readable using any editor.
> stats01.py works on both "raw" and "pretty" json.
>
> The Calc import default parameters work for stats1.csv. The columns are
> comma delimited.
>
> Note: There is exactly one non-ASCII character in the statistics.
> Dealing with this took most of my debug time.
>
> I hope you find this helpful.
>
> SegundoBob
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: downloads.csv
Type: text/csv
Size: 814 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20121202/62096132/attachment.csv>
More information about the gnucash-devel
mailing list