Leading zeros dropped on Python SDK add_rows
We are using the smartsheet-python-sdk to insert rows into SmartSheets. For almost two years we have had this script running with no issue, but in the last week, SmartSheets has started to trim the leading zeros on fields that are all numeric. Nothing has changed in our sheet or in our script.
Are others having this issue? For you, did it also just recently begin? Have you found any solutions?
We are using the same version of the smartsheet-python-sdk that what we've always used.
We have tried appending an apostrophe on the front, which SmartSheets then recognizes as a string and keeps the zeros, but it also appends it's own apostrophe onto the string, making the value ''000999 - so the value displayed is '000999 , which will not suffice. We need the real value there without an extra character.
A chunk of the script is below. We are putting the data into a dictionary and running this function for the insert. I confirmed that the data in the dictionary, and the new cell value itself, has the zeros. The zeros are certainly being passed to SmartSheets. It's in SmartSheets that they are being dropped.
def add_new_data_to_smartsheet(data_dict, sheet_id):
rowsToAdd = []
# each object in data_dict represents 1 row of data
for i, i in data_dict.items():
# create a new row object
new_row = smartsheet_client.models.Row()
new_row.to_bottom = True
# for each key value pair, create & add a cell to the row object
for k, v in i.items():
if v is None:
continue
else:
# create the cell object and populate with value
new_cell = smartsheet_client.models.Cell()
new_cell.column_id = column_map[k]
new_cell.value = v
# add the cell object to the row object
new_row.cells.append(new_cell)
# add the row object to the collection of rows
rowsToAdd.append(new_row)
# add the collection of rows to the sheet in Smartsheet
result = smartsheet_client.Sheets.add_rows(sheet_id, rowsToAdd)
add_new_data_to_smartsheet(data_dict, sheet_id)
Best Answer
-
This is a recent API bug, being tracked in another Discussion thread with lots more details
Answers
-
This is a recent API bug, being tracked in another Discussion thread with lots more details
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 437 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives