insightindustry / spss-converter

A simple utility that converts SPSS data to / from Pandas DataFrames, CSV, Excel, JSON, YAML, and dict.
https://spss-converter.readthedocs.io/en/latest/
MIT License
9 stars 4 forks source link

read_json() got an unexpected keyword argument 'layout' #11

Closed mazbeh closed 1 year ago

mazbeh commented 1 year ago

Hello every body,

my question is maybe very simple but it is problem for me while i have no idea of programming -_- . so any help or tips will be appreciated , thanks ! i have a very simple code that must covert a json file into spss for me :

import spss_converter

as_spss = spss_converter.from_json('/home/user/file.json', target = '/home/user/my-spss-file.sav', layout = 'table')

but if i run the code with : python3 spss.py

i get the following error: TypeError: read_json() got an unexpected keyword argument 'layout'

I run it on Ubuntu ( Python 3.8.10 )

Thanks for your help !

insightindustry commented 1 year ago

Hi @mazbeh : Apologies, it looks like there's an error in the documentation. Rather than layout = 'table', you should pass the argument orient = 'table'.

If you take a look at the documentation for the .from_json() function (see here), you'll find that it only expects:

All other keyword arguments - like in this case orient - are passed directly to the pandas.read_json() function, so you can look at those options in the Pandas documentation here.

I'll fix the SPSS Converter documentation and re-release shortly.

insightindustry commented 1 year ago

Looking through the API and thinking about it a little more, I realized that it will be more consistent with the .to_* functions if I explicitly add support for the layout parameter to .from_json() and .from_yaml(). So that's what I will do, and I'll re-release a new version later today. In the meantime, you can feel free to use orient = 'table'` rather thanlayout = 'table'`` and it should work fine for you.

I'll re-close this issue when the next version is released.

insightindustry commented 1 year ago

Okay, I've released v.0.2.0 which addresses this issue. Thanks for bringing it to my attention!

mazbeh commented 1 year ago

@insightindustry thanks alot for replaying ! that is nice of ! i would try it again and let you know :)))