Skip to main content
Announcements
Do More with Qlik - Qlik Cloud Analytics Recap and Getting Started, June 19: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
olaoyesunday1
Contributor III
Contributor III

Reading from Qlik Cloud using python and pytoqlik

Hi all,

 I am trying to read Data from Qlik Coud through my python script using pytoqlik library. It does not have any issue when reading from BarCharts or combo chart but anytime I am reading from Pivot table I always encounter the problem below:

p2q = pytoqlik.Pytoqlik(api_key=key, tenant=url, appId=ID)

# Get data from Qlik Sense chart
table_data= p2q.toPy('55090c6e-5a54-4eab-8d45-637c67a30db7')

Here is the error: 

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 2
      1 # Get data from Qlik Sense chart
----> 2 table_data=p2q.toPy('sTjnxT')

File ~\anaconda3\Lib\site-packages\pytoqlik\module.py:515, in Pytoqlik.toPy(self, objId)
    512     rows.append(elem)
    514 df = pd.DataFrame(rows)
--> 515 df.columns = columns
    517 if (df.empty):  # No measures in object
    518     print(f'No data in {objId} object. Is it empty?')

File ~\anaconda3\Lib\site-packages\pandas\core\generic.py:6002, in NDFrame.__setattr__(self, name, value)
   6000 try:
   6001     object.__getattribute__(self, name)
-> 6002     return object.__setattr__(self, name, value)
   6003 except AttributeError:
   6004     pass

File ~\anaconda3\Lib\site-packages\pandas\_libs\properties.pyx:69, in pandas._libs.properties.AxisProperty.__set__()

File ~\anaconda3\Lib\site-packages\pandas\core\generic.py:730, in NDFrame._set_axis(self, axis, labels)
    725 """
    726 This is called from the cython code when we set the `index` attribute
    727 directly, e.g. `series.index = [1, 2, 3]`.
    728 """
    729 labels = ensure_index(labels)
--> 730 self._mgr.set_axis(axis, labels)
    731 self._clear_item_cache()

File ~\anaconda3\Lib\site-packages\pandas\core\internals\managers.py:225, in BaseBlockManager.set_axis(self, axis, new_labels)
    223 def set_axis(self, axis: AxisInt, new_labels: Index) -> None:
    224     # Caller is responsible for ensuring we have an Index object.
--> 225     self._validate_set_axis(axis, new_labels)
    226     self.axes[axis] = new_labels

File ~\anaconda3\Lib\site-packages\pandas\core\internals\base.py:70, in DataManager._validate_set_axis(self, axis, new_labels)
     67     pass
     69 elif new_len != old_len:
---> 70     raise ValueError(
     71         f"Length mismatch: Expected axis has {old_len} elements, new "
     72         f"values have {new_len} elements"
     73     )

ValueError: Length mismatch: Expected axis has 3 elements, new values have 6 elements

Please, how can I resolve this? 

Labels (5)
2 Replies
jprdonnelly
Employee
Employee

@olaoyesunday1 - I can't say exactly why this is failing, however I can indicate that this 3rd party library was last updated on Jun 24, 2021 and is most likely out-of-date.

The individual charts have evolved over the years, deployed first in Qlik Cloud and then rolling downhill into a Qlik Sense Enterprise on Windows release based on that release schedule. 

Additionally, there is now a new Pivot Table chart/object available as well and I imagine this community library cannot support other such updates over the last 2.5 years or so.

Please also follow the progress on our new Python SDK for Qlik Cloud.

- @jprdonnelly
olaoyesunday1
Contributor III
Contributor III
Author

Okay I see,  I will peruse the documentation of the SDK link you sent to me.

Thanks