I read a sav file using this code:
df_file, meta_data = pyreadstat.read_sav(‘path’)
It returns df_file
as pandas DataFrame but returns meta_data
as metadata_container object
. I need to share meta_data
object to a colleague who is not programmer. How do I export it? I can easily export df_file
because it is a DataFrame but can’t export meta_data
to something like JSON because it is not a DataFrame.
Not perfect but it's a first step, you can use meta.__dict__
import json
df, meta = pyreadstat.read_sav('path')
json.dump(meta.__dict__, open("metadata.json", "w"), indent=4)