11-17-2021 02:32 PM
I am attempting to automate my power supply. I found a VI online for my make/model and I am currently trying to adjust it to my needs. I did not attach a VI due to it being currently irrelevant.
I would like to read just one line of text at a time using "read from text file function". After the passing of this line I would like to move on to the next line after the rest of the program iterates once.
When I change the "read from text file function" to "read lines", I can no longer put a constant on the front panel for text. How can I iterate one line at a time? How can I put a constant on the front panel to display which line of text was read?
Solved! Go to Solution.
11-17-2021 03:01 PM
Constants don't go on the front panel, they go on the block diagram.
Do you mean you are having trouble creating a string indicator?
11-17-2021 03:24 PM
@paul_cardinale wrote:
Constants don't go on the front panel, they go on the block diagram.
Do you mean you are having trouble creating a string indicator?
...and THIS is why code is always relevant.
11-17-2021 04:53 PM
Just a guess, but you are probably missing the "count" input.
11-18-2021 02:28 PM
Hello,
Thank you for any help given. If you look at the snipit I attached, the top part where I added my own code is what im struggling with. I have a text file that I want to read as one line at a time, then for the for loop to iterate, then read the next line, etc, so naturally, I see use shift registers. Why does the "Not equal?" function dislike my input? Does my "read from text file" node need to be outside the current for loop? (I am still very new to labVIEW and I am trying to add to a complicated VI that is made by the creator of my power supply in order to automate the power supply)
I will attach the full vi zip file... to access the file I am referring to, go to examples->Eurotherm 35xx Series Temperature Controller
Thank you!
11-18-2021 02:36 PM
This could have been continued in the previous thread as well - https://forums.ni.com/t5/LabVIEW/Read-from-text-file-by-line/m-p/4192511
Anyway, let this be a new topic.
11-18-2021 03:40 PM
Where in the menu tree is that read file by lines. I have a copy of one that reads lines starting a number of characters in that I have been carrying around since LV2012 or earlier.
I am using LV2019 so maybe it is something that they added back 2020 or later.
I need the starting at character number as I am reading really big files. What I would really like is read N lines starting at line M.
11-18-2021 03:55 PM
Unless the file is gigantic, I would recommend to read all lines, then process them line by line. A text file is just a long string of bytes and unless all lines have exactly the same number of characters, you cannot tell at what file position one line ends and the next begins, so no matter what, you should read as much as you possible can and do the rest of the parsing in memory.
As others have said, once you switch to lines, you get an array of strings instead of a plain string, so right-click your indicator and "change to array". You probably also need to adjust the code accordingly.
And yes, as you can now see, attaching code (possibly simplified to show the problem only) is always relevant. Your problem would have been solved in the first few responses. 😄
11-18-2021 06:18 PM
@Tom_Powers wrote:
Where in the menu tree is that read file by lines. I have a copy of one that reads lines starting a number of characters in that I have been carrying around since LV2012 or earlier.
I am using LV2019 so maybe it is something that they added back 2020 or later.
I need the starting at character number as I am reading really big files. What I would really like is read N lines starting at line M.
Right-click and select Read Lines option.
If you think about it, reading from line M for N lines, you first need to find the offset of line M which is not possible unless you read the entire file and look for new line characters because a text file is composed for a sequence of characters and not lines.
So, in any case, you need to read first N lines (simple as stop reading at N+1 occurrence of new line character)
11-19-2021 07:16 AM
Thanks. Although it does not have a start reading at byte input so you have to precede it by open file set position to N bytes after start.