03-31-2009 08:22 AM
Hello,
I`m quite new in using labview and I`m now dealing with my first isue. I have got a text file of measured raw data. The text tile looks like this:
"Text Type";"Flexure"
"Final linear density";100.000000;"tex"
"Custom text input 1";""
"Time sec";"Extension mm";"Load N";"Flexure stress MPa";"Cycle Count ";"Total Cycle Count ";"Repetitions Count ";"Marked Data ";"PIP Count ";
0;0;0,3586976;-0,7188803;0;0;0;0;0;0;0;-0,3586976;0;0
0,01;0;0,3380042;-0,6774079;0;0;0;0;0;0;0;-0,3380042;0;0
0,03;-5,66667e-005;0,3339654;-0,6693135;0;0;0;0;0;5,66667e-005;0,0002499001;-0,3339654;0;-5,66667e-005
What I need is to extract numbers from first and second column (each column separated by ";") to an array and then transpose them so that I can plot them into a graph.
Could anyone help me or point me to the right study source?
I have tried to use Scan from File and Read from spreadsheet VIs but either didn`t work.
The description clarified in help is not clear enough for me.
Thank you a lot for helping me in doing first bigger steps with LabView.
Martin
Solved! Go to Solution.
03-31-2009 08:32 AM
Hi Martin,
you can use the "Read from Spreadsheet File" function. Use "Array Subset" on the result to get what you need and plot it into your graph.
Mike
03-31-2009 10:43 AM - edited 03-31-2009 10:46 AM
Here's my first pass at parsing your data. Perhaps I've missed your intention?
It's not pretty, but it'll get you started.
03-31-2009 06:13 PM - edited 03-31-2009 06:14 PM
Thank you for possible solution and VI too. However, it seemed to me too much complicated and I don`t like loops 🙂
MikeS81:
Thanks for putting me in the right direction. I`ve managed it based on your recommended functions.The only problem that lefts is how to get rid off the initial mess in the file:
"Text Type";"Flexure"
"Final linear density";100.000000;"tex"
"Custom text input 1";""
"Time
sec";"Extension mm";"Load N";"Flexure stress MPa";"Cycle Count ";"Total
Cycle Count ";"Repetitions Count ";"Marked Data ";"PIP Count ";
I have tried to use "Match pattern" or "Match regular expression" as jcarmody showed in his solution. However, I think I get wrong the "offset past match". I would need something like " offset first match". Do you have any ideas how to solve this?
Martin
04-01-2009 02:01 AM
Hi Martin,
do you habe a fixed number of initial lines? If yes, then you can use the Array Subset function with a constant to get only the values you want.
Mike
04-01-2009 04:05 AM
Mike,
thank you for the tip. I also considered it but problem comes when there are more measured specimen. Then all the data are stored into one file so it looks like this:
"Text Type";"Flexure"
"Final linear density";100.000000;"tex"
"Custom text input 1";""
"Specimen 1"
"Time
sec";"Extension mm";"Load N";"Flexure stress MPa";"Cycle Count ";"Total
Cycle Count ";"Repetitions Count ";"Marked Data ";"PIP Count ";
0;0;0,3586976;-0,7188803;0;0;0;0;0;0;0;-0,3586976;0;0
0,01;0;0,3380042;-0,6774079;0;0;0;0;0;0;0;-0,3380042;0;0
0,03;-5,66667e-005;0,3339654;-0,6693135;0;0;0;0;0;5,66667e-005;0,0002499001;-0,3339654;0;-5,66667e-005
...
"Text Type";"Flexure"
"Final linear density";100.000000;"tex"
"Custom text input 1";""
"Specimen 2"
"Time
sec";"Extension mm";"Load N";"Flexure stress MPa";"Cycle Count ";"Total
Cycle Count ";"Repetitions Count ";"Marked Data ";"PIP Count ";
0;0;0,3586976;-0,7188803;0;0;0;0;0;0;0;-0,3586976;0;0
0,01;0;0,3380042;-0,6774079;0;0;0;0;0;0;0;-0,3380042;0;0
0,03;-5,66667e-005;0,3339654;-0,6693135;0;0;0;0;0;5,66667e-005;0,0002499001;-0,3339654;0;-5,66667e-005
I`m sorry, I didnt mention this fact before. However, it`s not important at this phase. I can handle it by writing several instructions for operators...
Thank you for very fast and helpful answers. My issue is solved.
I`m starting to like labview and its community 🙂
04-01-2009 06:01 AM - edited 04-01-2009 06:04 AM
The carrot in the regexp looks at the beginning of the string, if you remove it your regexp will return the index after the first number it finds. This isn't quite right, either, because you can have numbers in your headers. I changed the regexp as shown. If you subtract the length of the match from the offset past the match (and increment) you'll get the position of the first data row.
PS - You'll still have to use loops when your file has multiple headers. There are probably ways to do that with regular expressions, but I've never used them that way.