11-03-2014 05:04 AM
Hello!
I have a problem with reading a text file in LabView which I am sure is pretty easy to do but since I'm really new to labview (and programming at all) I am having a hard time figuring it out.
So basically I am using the "write to measurement file" VI to write some test results into a text file. I am just getting ones and zeros so the text file looks something like this:
1,00000
0,00000
1,00000
..
and so on .
I would then like to import these values to labview but I dont want the decimals and I would like everything on the same row, something like this:
1 0 1 0 etc etc.
(the idea is then being able to convert the values to a hexadecimal number 1-F, so for example the input above would translate to 6.)
I've tried to use the read from text file function but I don't know how to then convert the input to my desired format.
Also if you have any clue on how to make it start reading at the first 1 and then read the next 4 inputs that would be great as well.
Any help is really appreciated! 🙂
Solved! Go to Solution.
11-03-2014 06:06 AM
11-03-2014 11:26 AM
Hello,
thanks for the reply! Is this what you are suggesting?
I have tried something similar before but as you can see I dont get what I want.. Feels like Im missing something, you have any idea what?
Thanks again!
11-03-2014 11:33 AM
Is anything in the loop supposed to happen in a particular order? It's hard to tell from the picture because I have no idea if the the file paths are even related.
11-03-2014 11:40 AM
Just read the entire file as one long string, search for newline characters, and look at the character right after each.
11-03-2014 11:42 AM
11-03-2014 11:43 AM
This sounds exactly like an idea for a solution that I had but couldnt find the functions to do it, do you have any idea which ones to use?
11-03-2014 11:57 AM
Heres the file! Yeah I realise the loop is kinda pointless.. Like I said Im really new to programming at all!
Its a lvm file but I put the settings so I only get the 1's and zeroes, figured it would be easier to read that way..
I tried using the read from measurement file but kept getting an error saying " end of file reached" every time i tried to read it. (Even the first time, I am aware of the issue with recieving the error the second time reading as i read some forum posts about that)
11-03-2014 12:21 PM
After you read the file and convert the strings to 1 and 0, how will those values be converted into the "hexadecimal number" you mentioned? Are all the values used for one number or will the data in the file represent multiple numbers? If so, how many "bit" per number?
The code shown below will read the file you posted and convert the data into a single number (expressed here as decimal). The hex equivalent is C002.
Lynn
11-03-2014 12:22 PM
something like this
You need to declair the decimal separator