Python API: tokenizing error when using variant KPI in query

#1

Hi all,

We’re experimenting with the Python API and things as pulling and pushing data works, however when I run the following code:

#Variants
q_variant = Query()
#TODO internal error when adding the variants...
q_variant.add(Dimension('"act.csv"."KEY1"'))
q_variant.add(Dimension('"act.csv"."KEY2"'))
q_variant.add(KPI('VARIANT("act.csv"."NAME")'))
df_variants = datamodel.query(q_variant)

I get:
Traceback (most recent call last):

  File "<ipython-input-217-4922802c21ba>", line 1, in <module>
    df_variants = datamodel.query(q_variant)

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 1843, in query
    return execution.fetch_result(encoding=encoding, **kw)

  File "C:\dev\Anaconda\lib\site-packages\celonis_tools\model\folder.py", line 1580, in fetch_result
    df = pd.read_csv(tmp_filename, **kw)

  File "C:\dev\Anaconda\lib\site-packages\pandas\io\parsers.py", line 678, in parser_f
    return _read(filepath_or_buffer, kwds)

  File "C:\dev\Anaconda\lib\site-packages\pandas\io\parsers.py", line 446, in _read
    data = parser.read(nrows)

  File "C:\dev\Anaconda\lib\site-packages\pandas\io\parsers.py", line 1036, in read
    ret = self._engine.read(nrows)

  File "C:\dev\Anaconda\lib\site-packages\pandas\io\parsers.py", line 1848, in read
    data = self._reader.read(nrows)

  File "pandas\_libs\parsers.pyx", line 876, in pandas._libs.parsers.TextReader.read

  File "pandas\_libs\parsers.pyx", line 891, in pandas._libs.parsers.TextReader._read_low_memory

  File "pandas\_libs\parsers.pyx", line 945, in pandas._libs.parsers.TextReader._read_rows

  File "pandas\_libs\parsers.pyx", line 932, in pandas._libs.parsers.TextReader._tokenize_rows

  File "pandas\_libs\parsers.pyx", line 2112, in pandas._libs.parsers.raise_parser_error

ParserError: Error tokenizing data. C error: Expected 26 fields in line 28, saw 28

We’re using Celonis 4.4, Python 3.7 and the Python library as downloaded last week from my.celonis.de.
We did not install the PyOrc package, b/c we’re using Python 3.7, could this be related?

0 Likes

#3

You’re right! This is related to not using pyorcloader. We highly recommend doing all data transfer related tasks by first installing pyorcloader when using Celonis Process Mining 4.3 or 4.4. Downgrading to Python 3.6 or upgrading Celonis Process Mining to 4.5 would be the best short term solution.

3 Likes

#4

Thanks Simon for the quick and clear reply, we’ll wait until our sys admins upgrade to 4.5 :slight_smile:

0 Likes