Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

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

Posted on October 20, 2021October 20, 2021 by Tom

“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

Summary

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.


πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

4 thoughts on “How to process .csv attachment of SP item with Power Automate”

  1. John Ohlund says:
    October 21, 2021 at 6:41 am

    Been trying to solve this issues all week! Processing a CSV attachment from email and could not get the actual data contents. This worked like a charm – too bad we have to add the additional steps but oh well.

    Reply
  2. Joey O'Neil says:
    October 22, 2021 at 7:57 pm

    Great stuff, will presented article.

    Did you try using the any of the base64(…) expressions to convert the content? I believe that should work without having to convert it to a TXT file.

    I saw a similar solution here:
    https://www.google.com/amp/s/sharepains.com/2020/03/09/read-csv-files-from-sharepoint/

    Reply
  3. Joey O'Neil says:
    October 22, 2021 at 8:29 pm

    The specific expression would be:
    base64ToString(outputs(‘Get_attachment_content’)?[‘body/$content’])

    Then you can split that output on \r\n (CrLf) to get an array of the individual rows.

    At least this worked for me. πŸ™‚
    As they say, “your mileage may vary”, so it’s possible this won’t’ work in your scenario.
    Just thought I’d pass this along.

    Reply
    1. Tom says:
      October 24, 2021 at 3:04 pm

      Hello Joey,
      thank you for the comment, that’s what I tried first, but the result was as unusable as the encoded string: https://tomriha.com/wp-content/uploads/2021/10/base64toStringcsv.png.

      Reply

Leave a Reply Cancel reply

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

πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Still exchanging emails to get things approved?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy an automated, fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundleβ€”everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes