Skip to main content

Posts

Showing posts with the label ascii

How to read data from text (.txt) file with Ascii

It returns a container with the data in each line in the text file. That could be useful if you are reading a CSV file. In the following example I convert the container into text string and print it as an info message, line after line: void method1() { AsciiIo readFile; str line; container fileRecord; ; readFile = new AsciiIo("C:\\test.txt" , 'R'); readFile.inFieldDelimiter("1234567890abcdefghijklmnop"); fileRecord = readFile.read(); while (fileRecord) { line = con2str(fileRecord); info(line); fileRecord = readFile.read(); } } This is content of the text file: And that is the output generated with the code sample above: