cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
190 stars 109 forks source link

Transfer data from csv file to cube #411

Closed jace112233 closed 4 years ago

jace112233 commented 4 years ago

Hi,

I am trying to transfer data from a csv file to a cube. But I have encounter an error which is "can not be found in collection of type 'Element'."}} " . Can you guide on the way I should input the values in the csv file.

This is the data from the csv file image

The is how my cube view looks like image

This is the code that I have used image

rkvinoth commented 4 years ago

Do you follow the cube dimension order in the cellset? If not correct it.

If you still have issues, provide the code in text format and not as an image.

jace112233 commented 4 years ago

Do you follow the cube dimension order in the cellset? If not correct it.

If you still have issues, provide the code in text format and not as an image.

Hi , this is the code I encounter

TM1pyRestException: Text: {"error":{"code":"278","message":"'2020,NR-DZ600MB' can not be found in collection of type 'Element'."}} Status Code: 404 Reason: Not Found Headers: {'Content-Length': '120', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}

scrambldchannel commented 4 years ago

Your file looks messed up. You seem to be expecting it to be semicolon delimited but you seem to have a mix of commas and semicolons, hence you're not splitting 2020 and NR-DZ600MB. Also, you seem to expect all columns to be quoted but your image suggests the first column isn't.

More generally, I wouldn't rely on Excel to show you what's actually in your csv file. Also, if you find yourself removing quotes manually from column values, you might want to look at the csv library.

rkvinoth commented 4 years ago

I think you have a good idea of how to load data into TM1. Just make sure you follow the dimension order of the cube in each key in the cellset. You have to get your csv file sorted at the source or take this question to stackoverflow, as we have lot of python gurus there who can definitely provide you a better solution. I believe this issue can be closed as it is no way related to TM1PY.