Understanding Parsing Error when reading model file into PySD
<p>I am receiving the following error message when I try to read a Vensim model file (.mdl) using Python's PySD package.  </p>

<p>My code is:</p>

<pre><code>import pysd
import os

os.chdir('path/to/model_file')

model = pysd.read_vensim('my_model.mdl')
</code></pre>

<p>The Error I receive is:</p>

<pre><code>Traceback (most recent call last):
  Python Shell, prompt 13, line 1
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pysd/pysd.py", line 53, in read_vensim
    py_model_file = translate_vensim(mdl_file)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pysd/vensim2py.py", line 673, in translate_vensim
    entry.update(get_equation_components(entry['eqn']))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pysd/vensim2py.py", line 251, in get_equation_components
    tree = parser.parse(equation_str)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/parsimonious/grammar.py", line 123, in parse
    return self.default_rule.parse(text, pos=pos)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/parsimonious/expressions.py", line 110, in parse
    node = self.match(text, pos=pos)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/parsimonious/expressions.py", line 127, in match
    raise error
parsimonious.exceptions.ParseError: Rule 'subscriptlist' didn't match at '' (line 1, column 21).
</code></pre>

<p>I have searched for this particular error and I cannot find much information on the failed matching rule for 'subscriptlist'. </p>

<p>I appreciate any insight. Thank you.</p>

<p>Good news is that there is nothing wrong with your code. =) (Although you can also just include the path to the file in the <code>.read_vensim</code> call, if you don't want to make the dir change). </p>

<p>That being the case, there are a few possibilities that would cause this issue. One is if the model file is created with a sufficiently old version of Vensim, the syntax may be different from what the current parser is designed for. One way to get around this is to update Vensim and reload the model file there - Vensim will update to the current syntax.</p>

<p>If you are already using a recent version of Vensim (the parser was developed using syntax of Vensim 6.3E) then the parsing error may be due to a feature that isn't yet included. There are still some outstanding issues with subscripts, which you can read about <a href="https://github.com/JamesPHoughton/pysd/issues/71" rel="nofollow">here</a> and <a href="https://github.com/JamesPHoughton/pysd/issues/70" rel="nofollow">here</a>).</p>

python vensim