Description
This activity is used to read the content of a text file.
Similar to other activities related to reading files, an 'Assign value to variable' action block connected to this block will also appear upon adding this block to the workflow. This variable will store the contents of the read file.
However, using the 'Assign value to variable' activity is not strictly necessary in this case. It is safe to delete this block and handle the result any other way. For example, if you want to send the content of the text file in an email 'as is', i.e. without changing the content in any way then you could use the 'Send email' activity right after 'Read text file' and specify the Save the previous step result option in the Body parameter.
Parameters
This activity has three parameters: File type, Path (required), and Encoding.
Speaking of File type, there are two options. You can either choose any common text tile format such as .txt, .log, .ini, and others or JSON format.
File type parameter
If the JSON option is selected, the output of this will be a variable of object type (JavaScript). This means that you can easily address the keys and values, for example, file_content[“name”].
The Path parameter lets you define the location of the file you are going to read. As usual, it can be set manually, dynamically, or by saving the previous step result. Also, you can specify the needed file using Explorer by clicking the 'Pick' button.
Path parameter
Encoding
This parameter allows you to specify the encoding, here is a full list of the supported ones: 437
, 737
, 775
, 850
, 852
, 855
, 856
, 857
, 858
, 860
, 861
, 862
, 863
, 864
, 865
, 866
, 869
, 874
, 922
, 1046
, 1124
, 1125
, 1129
, 1133
, 1161
, 1162
, 1163
, 1250
, 1251
, 1252
, 1253
, 1254
, 1255
, 1256
, 1257
, 1258
, 28591
, 28592
, 28593
, 28594
, 28595
, 28596
, 28597
, 28598
, 28599
, 28600
, 28601
, 28603
, 28604
, 28605
, 28606
, maccroatian
, maccyrillic
, macgreek
, maciceland
, macroman
, macromania
, macthai
, macturkish
, macukraine
, koi8r
, koi8u
, koi8t
, armscii8
, rk1048
, tcvn
, georgianacademy
, georgianps
, pt154
, viscii
, iso646cn
, iso646jp
, hproman8
, macintosh
, ascii
, tis620
, utf7
, utf8
, cesu8
, ucs2
, utf16
, utf16le
, utf16be
, binary
, base64
, hex
, 932
, shiftjis
, csshiftjis
, mskanji
, sjis
, windows31j
, ms31j
, xsjis
, windows932
, ms932
, cp932
, 936
, cp936
, gb2312
, gb231280
, gb23121980
, csgb2312
, csiso58gb231280
, euccn
, windows936
, ms936
, 949
, cseuckr
, csksc56011987
, euckr
, isoir149
, korean
, ksc56011987
, 950
, eucjp
, gbk
, gb18030
, big5
.
Results
Let us have a look at how the read text is represented. In this case, we used the 'Assign value to variable' action.
This is the source file we used for an example.
An example of a file to read
And this is how its contents are displayed in the variable.
The text from the file is written into this variable
A few notes about JSON format.
This is how a simple JSON file can look like in a variable.
The source JSON file
The variable with the file contents