#1 by oTreeCardinal
Hi all, I am currently using oTree as a part of some research. Currently, in my experiment I am using static data to mimic information needed for my experiment. However, this will not work when we need to deploy the real experiment. I am trying to read in another csv file from my local machine and parse an example template that will serve as a substitute for when the experiment is deployed on heroku. I am facing troubles trying to read in a csv file. I have tried differement methods from online sources but have not found a solution. Does anyone know if this problem is caused by how the Otree program is structured? Is there any way to do this at all?
#2
by
BonnEconLab
(edited )
I haven’t completely understood the issue. But maybe I can help nevertheless. In a project of mine, the following works: I place the CSV file in the same folder as the settings.py file. In settings.py, I include the respective commands for reading in the CSV file, such as import pandas as pd and DATA_FROM_CSV = pd.read_csv('My_CSV_file.csv') In the __init__.py of my apps, I can import these data via, e.g., from settings import DATA_FROM_CSV as settings_DATA_FROM_CSV settings_DATA_FROM_CSV can then be accessed wherever I like. I am pretty sure that one could also include DATA_FROM_CSV = pd.read_csv('My_CSV_file.csv') in an app’s __init__.py.