Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
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 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[16], line 2
      1 # Get data from Qlik Sense chart
----> 2 table_data= p2q.toPy('55090c6e-5a54-4eab-8d45-637c67a30db7')

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 9 elements, new values have 11 elements

 Please, what is the solution

Labels (2)
2 Replies
AfeefaTk
Support
Support

Hi @olaoyesunday1 

In this forum we would be able to help you with questions related to the product Qlik Application Automation.
This question seems to be related to Qlik Sense, if so, could you please post your question in that forum (https://community.qlik.com/t5/Qlik-Sense/ct-p/qlik-sense)?

Thanks

olaoyesunday1
Contributor III
Contributor III
Author

Thanks, I will post the Question there