From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read from text file and decode

Solved!
Go to solution

Hi, i am having a file that consists of 2 columns, first is time/date stamp and 2nd is ON/OFF as text.

 i want to determine the time-stamp when text is either ON or OFF. 

i am not able to parse the data into 2 seperate columns and then read, can anyone help me out on this?

Attached is the example of the file. 

 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 1 of 8
(4,176 Views)

youll want to open the text file read from text file and you can make use of the spreadsheet string to array.  Then index your array and then feed your on/off string to a case structure and perform your read/not read there.



-Matt
0 Kudos
Message 2 of 8
(4,154 Views)

We usually ask to see code (which you provide by attaching your VI).  This guards against "Do My Homework" requests, helps us understand the nature of the problem, gives us a better understanding of what you tried and what didn't work, allows us to "see the error for ourselves", enables us to "guess" if you are just getting started or are more experienced, etc.

 

So without code, here are some questions:

  • Can you read the text files and get an array of (single-line) strings?
  • Can you see a pattern that might suggest a parsing scheme?
  • Do you know how to use the various string functions that allow you to split strings, extract parts from strings, change a string into, say, the number it represents, etc.?

If you choose to answer these questions, I'd recommend also attaching any VIs you've written to attempt to solve this question.  It will also help provide the answer to the question "What is LabVIEW 10.0?" (the last numbered version I have is 8.6 ...).

 

Bob Schor

Message 3 of 8
(4,147 Views)

i did try that. however, all i ended up was seeing 9, 0 in the output array. Capture.PNG

 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 4 of 8
(4,142 Views)

I'm sorry that I wasn't clear.  I'm unable to execute your "picture", which is why I asked that you attach your VI (not a picture).

 

What do you see if you delete all of the code except the Read Text File function, and wire an indicator to its output?  Do you get a single line?

 

Now add the next function and wire indicators to all of its outputs.  [I'd do it, myself, but I don't have your code ...].  Read the Help documentation for the functions and play with them a bit until you understand them.

 

Read my other suggestions.  Don't you see an easier way to get started (based on the data you showed)?

 

Bob Schor

0 Kudos
Message 5 of 8
(4,135 Views)

You should use the Spread Spreadsheet File (in the File palette) to read your file as a 2D array of strings.  Then you can just do a search through the second colum to find the data you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(4,114 Views)
Solution
Accepted by LV_Enthu

I was going to throw out the solution, but bob and cruz are probably right that this is HW.

 

What is wrong with your above vi is that you are matching the pattern of OFF and ON, but you dont have an array, therefore your searching through your entire text file and on the first OFF you display the text in front of it. You need to first create an array from your spreadsheet string coming from the read text file. this can be done by either using a spreadsheet string to array function or as cruz stated the spreadsheet file. Im not sure of your desired final output, but from there you may want to feed it into a for loop and search each element for ON or OFF.

 

That should get you started.



-Matt
Message 7 of 8
(4,101 Views)

Use Read SpreadSheet String Function, you will get output like this.SpreadSheet String.PNG

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 8 of 8
(4,083 Views)