Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

write a xlsm file to a Dataiku folder

Level 1
write a xlsm file to a Dataiku folder

I have an xlsm file and have loaded it from a Dataiku folder and changed a few cells using openpyxl. Now I would like to save it back to the Dataiku folder without loosing the macros. Is there a way to make the below work?

file = folder.get_download_stream(my_input_file_path)
output = BytesIO()
shutil.copyfileobj(file, output)
wb = openpyxl.load_workbook(output, read_only=False, keep_vba=True)
ws = wb[sheet_name]

ws['B2'] = 'something'
ws['X6'] = 'something else''my_file.xlsm')

with folder.get_writer('my_file.xlsm') as writer:
1 Reply

Hi @Thomas_11 ,

That should work are you seeing a specific issue/error?

Since you are using you can use read() or getvalue()  on the byteIO object.

The get_writer method would work for both remove/local folders. 
You can also use upload_stream().

with folder.get_writer("filename.xlsm") as writer:


0 Kudos