How to process .csv attachment of SP item with Power Automate

“I need to parse a .csv attached to a SharePoint item, but Power Automate turns the attachment into a complete mess, how can I keep the original csv format?”

When you trigger flow on a .csv file uploaded in a SharePoint document library, Power Automate will read it as .csv. It’ll have the expected format, and you can parse it as needed. But that’s not true if you upload a .csv file as item attachment. If you use the ‘Get attachment content’ on a .csv attachment, the content will be encoded. All the easily readable data is gone, together with the simple processing possibilities.

Power Automate csv item attachment

Save the file as .txt

You can try some conversion to turn it back, but I didn’t find any that works. But what does work is to save the file as a text file (.txt).

Create a library on the SharePoint site, e.g. ‘Attachments’. It’ll serve as a storage for the attachment files. Then, in the flow, ‘Get all attachments’ from the item…

… and ‘Get attachment content’ for all of them. At this moment it doesn’t matter that you can’t read it.

Once you have the attachment content, you can ‘Create file’ in the document library using the original file name with added ‘.txt’ to it. You might need to update the file if it already exists, but that way you’ll handle the conversion back to the original csv format.

The last step is to ‘Get file content’ of the new txt file. It’ll have the original csv format which you can now easily process.

Power Automate csv item attachment


Processing .csv in Power Automate can be tricky if you upload it as an item attachment. SharePoint will encode it on the background and flow won’t be able to read it easily. But with this workaround, saving the attachment as a file in a document library, you can turn it back.

And it’s actually quite beneficial workaround. Such library will give you a backup in case somebody deletes the attachment by mistake as deleted attachments are otherwise lost forever.

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.


Add a Comment

Your email address will not be published. Required fields are marked *