2424 )
2525
2626
27- def read_xmile (xmile_file , data_files = None , initialize = True ,
28- missing_values = "warning" ):
27+ def read_xmile (xmile_file , data_files = None , data_files_encoding = None ,
28+ initialize = True , missing_values = "warning" ):
2929 """
3030 Construct a model from a Xmile file.
3131
@@ -38,9 +38,20 @@ def read_xmile(xmile_file, data_files=None, initialize=True,
3838 If False, the model will not be initialize when it is loaded.
3939 Default is True.
4040
41- data_files: list or str or None (optional)
42- If given the list of files where the necessary data to run the model
43- is given. Default is None.
41+ data_files: dict or list or str or None
42+ The dictionary with keys the name of file and variables to
43+ load the data from there. Or the list of names or name of the
44+ file to search the data in. Only works for TabData type object
45+ and it is neccessary to provide it. Default is None.
46+
47+ data_files_encoding: list or str or dict or None (optional)
48+ Encoding for data_files. If a string or None is passed this
49+ value will be used for all the files. If data_files is a list,
50+ a list of the same length could be used to specify different
51+ encodings. If data_files is a dictionary, a dictionary with the
52+ same keys could be used, being the values the encodings. See
53+ documentation from pandas.read_table for further information.
54+ Default is None.
4455
4556 missing_values: str ("warning", "error", "ignore", "keep") (optional)
4657 What to do with missing values. If "warning" (default)
@@ -75,15 +86,20 @@ def read_xmile(xmile_file, data_files=None, initialize=True,
7586 py_model_file = ModelBuilder (abs_model ).build_model ()
7687
7788 # load Python file
78- model = load (py_model_file , data_files , initialize , missing_values )
89+ model = load (
90+ py_model_file ,
91+ data_files , data_files_encoding ,
92+ initialize ,
93+ missing_values
94+ )
7995 model .xmile_file = str (xmile_file )
8096
8197 return model
8298
8399
84- def read_vensim (mdl_file , data_files = None , initialize = True ,
85- missing_values = "warning" , split_views = False ,
86- encoding = None , ** kwargs ):
100+ def read_vensim (mdl_file , data_files = None , data_files_encoding = None ,
101+ initialize = True , missing_values = "warning" ,
102+ split_views = False , encoding = None , ** kwargs ):
87103 """
88104 Construct a model from Vensim `.mdl` file.
89105
@@ -96,9 +112,29 @@ def read_vensim(mdl_file, data_files=None, initialize=True,
96112 If False, the model will not be initialize when it is loaded.
97113 Default is True.
98114
99- data_files: list or str or None (optional)
100- If given the list of files where the necessary data to run the model
101- is given. Default is None.
115+ data_files: dict or list or str or None
116+ The dictionary with keys the name of file and variables to
117+ load the data from there. Or the list of names or name of the
118+ file to search the data in. Only works for TabData type object
119+ and it is neccessary to provide it. Default is None.
120+
121+ data_files_encoding: list or str or dict or None (optional)
122+ Encoding for data_files. If a string or None is passed this
123+ value will be used for all the files. If data_files is a list,
124+ a list of the same length could be used to specify different
125+ encodings. If data_files is a dictionary, a dictionary with the
126+ same keys could be used, being the values the encodings. See
127+ documentation from pandas.read_table for further information.
128+ Default is None.
129+
130+ data_files_encoding: list or str or dict or None (optional)
131+ Encoding for data_files. If a string or None is passed this
132+ value will be used for all the files. If data_files is a list,
133+ a list of the same length could be used to specify different
134+ encodings. If data_files is a dictionary, a dictionary with the
135+ same keys could be used, being the values the encodings. See
136+ documentation from pandas.read_table for further information.
137+ Default is None.
102138
103139 missing_values: str ("warning", "error", "ignore", "keep") (optional)
104140 What to do with missing values. If "warning" (default)
@@ -155,14 +191,19 @@ def read_vensim(mdl_file, data_files=None, initialize=True,
155191 py_model_file = ModelBuilder (abs_model ).build_model ()
156192
157193 # load Python file
158- model = load (py_model_file , data_files , initialize , missing_values )
194+ model = load (
195+ py_model_file ,
196+ data_files , data_files_encoding ,
197+ initialize ,
198+ missing_values
199+ )
159200 model .mdl_file = str (mdl_file )
160201
161202 return model
162203
163204
164- def load (py_model_file , data_files = None , initialize = True ,
165- missing_values = "warning" ):
205+ def load (py_model_file , data_files = None , data_files_encoding = None ,
206+ initialize = True , missing_values = "warning" ):
166207 """
167208 Load a Python-converted model file.
168209
@@ -182,6 +223,15 @@ def load(py_model_file, data_files=None, initialize=True,
182223 file to search the data in. Only works for TabData type object
183224 and it is neccessary to provide it. Default is None.
184225
226+ data_files_encoding: list or str or dict or None (optional)
227+ Encoding for data_files. If a string or None is passed this
228+ value will be used for all the files. If data_files is a list,
229+ a list of the same length could be used to specify different
230+ encodings. If data_files is a dictionary, a dictionary with the
231+ same keys could be used, being the values the encodings. See
232+ documentation from pandas.read_table for further information.
233+ Default is None.
234+
185235 missing_values : str ("warning", "error", "ignore", "keep") (optional)
186236 What to do with missing values. If "warning" (default)
187237 shows a warning message and interpolates the values.
@@ -195,4 +245,9 @@ def load(py_model_file, data_files=None, initialize=True,
195245 >>> model = load('../tests/test-models/samples/teacup/teacup.py')
196246
197247 """
198- return Model (py_model_file , data_files , initialize , missing_values )
248+ return Model (
249+ py_model_file ,
250+ data_files , data_files_encoding ,
251+ initialize ,
252+ missing_values
253+ )
0 commit comments