I have a text file ( as attached) with 8 lines of string data. I want to read this file and store it in 1D array so i can index any line as per requirement. How can I do so?
Read in the text (as a long string). Then feed a while- loop with this string and search for EOL-characters. This way you can split up your string into several shorter strings. If you output them in your while-loop (with indexing enabled) you get an array of strings.
Best regards Gerd
Best regards, GerdW
using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Read in the whole file (Read characters from File.vi), and use "spreadsheet string to array.vi" from the string functions. Rember to use the correct delimiter, it seems like the data file used Tab, so default should be fine. The result will be a 2D array of strings.
Step 1: Open the file. Step 2: Enter into a while loop. Step 3: With each loop iteration, read a single line of the file using the File Read vi, with the Line Mode set to TRUE. This will automatically read in a single line at a time. Step 4: Stop the loop on a File Read error. This means that we hit the end of the file. Step 5: Output the string array (which we have created by auto-indexing the string output from File Read). Step 6: Close the file.
Absolutely. Thank you guys for helping me out here. Thats why i so love this forum that i spend every spare minute online. Thaks to all here who have tried to help me :)I hope to look for your continuing support in future.