[STATS] Wanikani PyStats - Generate a Spreadsheet from your review history

Hi all,

A lot of the statistics sites use either API v1 or didn’t have the graphs I want. The solution to this is, of course, was to write a script to scrape the Wanikani API V2 and get a spreadsheet that doesn’t limit what I can do with it.

Wanikani PyStats is a python script that scrapes the wanikani API and generates quite comprehensive semicolon-limited CSV-file you can load into your favorite spreadsheet software. You can use it however you want to visualize your data, see how bad or well your accuracy has been doing or even compare different statistics to an another one.

To save the poor WaniKani’s servers, the script will retrieve all of the subjects when you run it for the first time and then cache them into a subjects.csv file. If you remove the file or the script realizes there’s something wrong with it, it will be redownloaded.

The format of the CSV-file is loosely based on Self-updating WaniKani Statistics & Data Spreadsheet so technically you can just copy the missing information from the result of this script. You can also create graphs like with WaniKani Timemachine or visualize the data however you want!

Preview

This is how the file is formatted in a text form.

And in Excel:
EXCEL_2020-04-01_19-50-47

Usage instructions

  1. Install Python 3.
  2. Download the script and save it somewhere.
  3. Grab your V2 API key from here: LINK
  4. Add your API key between the quotation marks to the api_V2 = "" on row 12.
  5. Run the script with py wanikani.py

If it complains about missing dependencies while trying to run it, just run pip install [dependency's name] without brackets.

If you want to use the file in excel:

  1. Open file in excel
  2. Select the first column
  3. Go to “Data” and choose “Text to columns”
  4. Choose “Delimited” and press Next
  5. Add “Semicolon” as the delimiter and press Next
  6. Change the first column to “Date” and press Finish

Download links

Download the script from here: LINK
Visit the repository: LINK

15 Likes

I love you.

3 Likes

This is a life saver :heart: :heart: :heart:

1 Like

Hi all!

There was a small bug in calculating the total reviews but that is now fixed. I also added a warning to inform you if the API key is not entered. Please download the latest version to have correct stats!

Affected columns were “Total reading reviews”, “Total Meaning Reviews” and “Total review number”. It is however suggested to replace all of the previous rows to fix any inaccuracies that might have occurred.

1 Like

Do you account for resets? Because I show up as level 60, even though I’m only 33.

1 Like

The script is not working for me today.
It keeps reloading the subjects. After reaching 100% it says
Error reading the subjects, redownloading from the server.
and it enters an infinite loop.

If I prevent the looping the subjects.csv looks okay:

$ ls -l subjects.csv
-rw-rw-r-- 1 jean jean 214186 Sep 11 09:20 subjects.csv

$ head subjects.csv
subject_id;subject_level;subject_type;characters
1;1;radical;一
2;1;radical;ハ
3;1;radical;丶
4;1;radical;七
5;1;radical;丿
6;1;radical;亅
7;1;radical;二
8;1;radical;亠
9;1;radical;人

$ tail subjects.csv
8916;40;vocabulary;妖しい
8917;35;vocabulary;喋る
8918;36;vocabulary;鮭
8919;39;vocabulary;宛名
8920;49;vocabulary;蹴る
8921;49;vocabulary;一蹴する
8922;41;kanji;喧
8923;41;kanji;嘩
8924;41;vocabulary;喧嘩
8925;41;vocabulary;喧しい

Error reading the subjects, redownloading from the server.
and it enters an infinite loop.

I had the same issue, it seems they modified the data model. I removed these lines:

starting_srs_stage_name = entry['data']['starting_srs_stage_name']
#...
ending_srs_stage_name = entry['data']['ending_srs_stage_name']

in lines 224 and 226.
These lines were only necessary if you “wanted the reviews in an csv format”, which is commented out in default. (line 353)

2 Likes

Thank you very much. That worked!

1 Like

Huge thanks!

P. S. Also, sorry if it’s a stupid question, but at lines 28 and 29

SUBJECTS = open(path_subjects, "a", encoding="utf-8")
DAYSTATFILE = open(path_daystats, "w", encoding="utf-8")

I’ve looked the script and I didn’t see SUBJECTS.close() and DAYSTATFILE.close() anywhere… Is it ok?

1 Like

It’s not completely nice, but the close() is implicitely done when the script exits.

2 Likes