Skip to content

Instantly share code, notes, and snippets.

@MariusWirtz
Created January 17, 2023 15:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MariusWirtz/751c153a568d0f029c65f701fc6c03c8 to your computer and use it in GitHub Desktop.
Save MariusWirtz/751c153a568d0f029c65f701fc6c03c8 to your computer and use it in GitHub Desktop.
write-to-tm1-cloud.py
from io import StringIO
import pandas
from TM1py import TM1Service
csv_string = """
Customer,Employee,Date,City,Country,Measure,Value
DUMO,1,1996-09-20,Nantes,France,Quantity,24.69
ALFKI,1,2022-08-02,Bern,Switzerland,Quantity,34
ALFKI,1,2022-09-11,Bern,Switzerland,Quantity,10.5
"""
with TM1Service(
base_url='https://company.planning-analytics.ibmcloud.com/tm1/api/tm1',
user="company01_tm1_automation",
namespace="LDAP",
password="",
ssl=True,
verify=True,
async_requests_mode=True) as tm1:
df = pandas.read_csv(
StringIO(csv_string),
sep=",",
dtype={"Customer": str, "Employee": str, "Date": str, "City": str, "Country": str, "Measure": str,
"Value": float})
tm1.cells.write_dataframe("Northwind Sales", df, use_ti=True, increment=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment