How to Split Text (TXT) files by Delimiter in Power Automate
In another article, we walked through the process of splitting up text (txt) files line-by-line in Power Automate. In this article, we’ll walk through a similar text-splitting process which might be preferrable to some folks.
Specifically, we’ll learn how to split text files by a string delimiter of our choosing. This is a great option to use if the contents of our text files (i.e., CSV data files, system logs, code, etc.) are neatly delimited in a way that already separates the information we want into manageable chunks.
Split text in Power Automate by a custom string delimiter
We’ll see how this works in a quick instant cloud flow. Just like before, we’ll use a Cloudmersive Document Conversion connector action to handle our text splitting process.
Retrieve text content with a Get file content action
We’ll first use a Get file content action to retrieve a text file from our system. In my example, I’ll be using a text file with lines from a Lorem Ipsum passage.
Search for Cloudmersive connectors
Next, we’ll search the Power Automate connector library for Cloudmersive connectors. We’re looking for the Cloudmersive Document Conversion connector with the green logo.
Locate the Split text by delimiter action
We’ll click “See more” to view the full actions list, and from there, we’ll search for an action titled Split a single Text file (txt) by a string delimiter.
Create a Cloudmersive API connection
After we select this action, we’ll need to create our Cloudmersive API connection. To do that, we’ll need a Cloudmersive API key, and we can get one by visiting the Cloudmersive website & creating a free account.
For reference, I’m using a free API key in this walkthrough. Free API keys allow up to 800 API calls/month across all Cloudmersive connectors in Power Automate.
Configure the Split text by delimiter request
To configure our request, we’ll first supply our text file content & a file name in the initial two request parameters (the file name can be anything — it doesn’t have to be the name of our actual input file).
After that, we’ll enter the string delimiter we’re using to split up our text files.
In the above screenshot of my flow, I’m simply hitting the “enter” key on my keyboard and setting that as my string delimiter. This tells the API to return a new chunk of my text file any time an empty line is encountered. It’s just one way to do this; if we’re using a CSV file to test this out, we would just as easily enter a comma (“,”) to return each individual piece of data in our file.
Save and test the flow
Now that we’ve configured our text splitting action, we’ll save our flow and run a quick test.
After we finish our test, we’ll open our text splitting action and review our response body.
My original Lorem Ipsum text file contained one paragraph of text per line. Because I chose to use line spacing as my delimiter, the API returned each individual line from my original file. This is the exact same outcome as the process we covered in the prior article I references, only accomplished a different way.
Conclusion
In this article, we learned how to split text files into chunks using a custom-entered string delimiter. We learned this in the context of a quick instant cloud flow, but the concept is applicable to a wide range of flows — particularly those used to process plain text content through Power Automate.