
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Reading from Qlik Sense through Python Script using pytoQlik library
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@olaoyesunday1, what is the data you are trying to extract? what does the pivot-table in Qlik looks like.
the error here looks clear:
- the pivot table got 6 elements. the code expected 3 elements therefore an error occured.
but please look close here. the error doesn't occure in Qlik or the Py2Qlik. It occures in the pandas dataframe
please take a look at this. it can be that the library you are using is using an old pandas version.
