Replace Text

Replace all instances of the comma (,) with a pipe (|) in a comma delimited text file

This task will demonstrate how Automate can read the data contained in a comma delimited text file and replace all instances of the comma (,) with a pipe (|). The new data will be displayed in a message box and then written to a new text file. In order for this task to work properly, please create a text file named comma_delimited.txt in your c:\ drive and paste the following data to it:

First Name, Last Name, Address, Home Number, Mobile Number, Email Address 

The actions to this task are as follows:

1. 'Create Variable' action is used to create a variable named 'theOriginalText' which will hold the value of the data contained in the specified text file.
2. Another 'Create Variable' action is used to create a variable named 'theNewText' which will hold the value of the modified data.
3. 'Read from File' action is used to read the data from a file and places the data in the variable named 'theOriginalText'.
4. The 'Replace Text' action finds and replaces each or every occurrence of a text pattern and places the result into the variable. In this case, it looks for all commas (,), replaces the character with a pipe (|) and places the result into the variable named 'theNewText'.
5. A 'Message Box' displays the original data along with the newly converted data. 
6. The 'Write to File' action writes the data specified to a file. If written to an existing file, the data is either overwriting the file or is appended at the end of the file. In this case, however, the data is written to a new text file named c:\pipe_delimited.txt

Task Category:

Functions (Basic)