Skip to main content

Get file as text

This time, I will explain how to acquire a specific file as a text data, and how to deal with it if the acquired data is garbled.

implemented with copy and paste

We have prepared a sample flow to capture text files stored in public documents in Ansi format.

Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.

File.ReadTextFromFile.ReadText File: $'''C:\\Users\\Public\\Documents\\document.txt''' Encoding: File.TextFileEncoding.ANSI Content=> FileContents

Operate and implement Power Automate Desktop

  1. Enter "Read text from file" from "Search Action" and set the property as follows.
Parameter namevalue
File pathTarget file path
How to save contentsSelect whether to be imported as one variable or a list
EncodingRead file character code
  1. When executed, the file data is stored as textbooks in the created variable.

When the acquired text data becomes garbled

The standard character code of the Japanese version of Windows is set in Shift-JIS (ANSI).In the case of Mac, it is UTF-8.

For data obtained from the web, UTF-8 is often used.

The action that reads text from the file has a property called "Encode" for specifying the character code, so this setting and the character code of the target file may not match.

If the characters are garbled in the UTF-8 setting, changing to the UTF-8 if the characters are garbled with ANSI can solve the garbled characters.