ztree2python

ztree2python

ztree2python imports a data file created by z-Tree (Fischbacher, 2007) into python as pandas dataframes. This function inputs the "filename" of a z-Tree data file, and it returns a dictionary, which contains the dataframes of the tables. The keys are the names of all tables, "globals", "subjects", and so on. The value associated with each key is a pandas dataframe for the table.

Installation

Use the package manager pip to install.

pip install ztree2python


Alternatively, simply put ztree2python.py and a z-Tree data file (e.g., 221215_1236.xls) in the current directory or the working directory.
For example, run the following commands.

from ztree2python import ztree2python as ztree2python
# input the file name, and it returns a dictionary. 
tables = ztree2python('221215_1449.xls')

The function returns a dictionary, name "tables" in this example. Each table is stored as a dataframe in the  "tables". Get the data of a table as follows:

# Extract a table by name, for example, the "subjects" table.
my_table = tables['subjects']
my_table.head()

For further information, please visit the github page. 

License

MIT. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.

Reference