LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Files into a Excel

I'm quite new to labview and attempting to take a generated data file, in which the data is not tab-delimited. I need to parse through this data finding certain lines within the file and convert it into a tab-delimited file with a different format.

This is the format of all the data in the original data file. In this instance I would need to pull data from 3 of the lines. Should I parse through and search for the title of each data section I need and go down "3" lines and copy data into a array?

 

DC VOLT METER TEST USING STM VOLTAGE SOURCE
P/F VOLTAGE RANGE TEST V0LTAGE DCVM VOLTAGE TOLERANCE
==== ============= ============ ============ =========
+/-200.00 V 7.9000 V 7.9139 V 1.6 %
+/-200.00 V -7.9000 V -7.9204 V 1.6 %
+/- 20.00 V 7.9000 V 7.9139 V 1.6 %
+/- 20.00 V -7.9000 V -7.9075 V 1.6 %
+/- 10.00 V 7.9000 V 7.9065 V 1.6 %
+/- 10.00 V -7.9000 V -7.9062 V 1.6 %
+/- 10.00 V 3.9260 V 3.9449 V 1.6 %
+/- 10.00 V -3.9260 V -3.9446 V 1.6 %
+/- 10.00 V 2.0025 V 2.0021 V 1.6 %
+/- 10.00 V -2.0025 V -2.0021 V 1.6 %
+/- 10.00 V 1.0044 V 1.0040 V 1.6 %
+/- 10.00 V -1.0044 V -1.0049 V 1.6 %

 

If you have any questions let me know.

 

Any help is appreciated!!!

0 Kudos
Message 1 of 8
(2,297 Views)

Use the Read Delimited Spreadsheet VI to load the file into an array.

dliniter.png

Once you have it in a array, do whatever you need to do to get the data you want formatted the way you want...

Then write the array to a new file using Write Delimited Spreadsheet VI

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 8
(2,267 Views)

Do you have experience (in other programming languages, such as C, Java, or Matlab) in handling Strings?  How comfortable are you with reading/writing Text files?

 

My suggestions would be to take this in steps (particularly since you can test each step to see if you are getting the data you expect).

  • Open the File.
  • Read a line at a time a string, building an array of strings (one per line).  It is much easier to work with a one-line String (and to do whatever-you-do over and over using Arrays and For loops) than having to worry about end-of-lines.
  • Decide what rows to keep, and discard the rest.
  • Decide how you want to parse your String, and do so.  A convenient output form (while developing) is to convert your String into an array of Strings (one per element), giving you a 2D array (elements by lines).
  • Once you have the parsing down, outputting the "User-separated" elements into a format you choose should be easy.

I'm assuming you are familiar with basic File I/O, Arrays, and For Loops.  Read the Help for the Read from Text File function to see how to make it read lines-at-a-time into an Array of Lines.

 

Bob Schor

0 Kudos
Message 3 of 8
(2,265 Views)

Can ou be more precise about the format you want, ideally with an example. Do you want only the numeric values in an array of double, an array of string with the units, ...

 

Parsing is not as straight forward as it seems since there is a space between numbers and units, a space between - and 2 in +/- 20.00 but no space between - and 2 in +/-200.00.

 

Ben64

 

 

0 Kudos
Message 4 of 8
(2,255 Views)

The final file should look as follows:

 

S/N Debug Date Time Operator P/N Test # Test Name Step # Expected Received Tolerance Step Passed? Test Passed?
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC VOLT METER 1 7.9 7.9075 0.1264 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC VOLT METER 2 -0.126 -0.126 -0.00164 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1   DC VOLTAGE SOURCE #1 3 0.00195 0.00195 1.500975 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC VOLT METER 1 -7.9 -7.9204 -0.1264 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC CURRENT METER 2 9.995 10.129 0.49975 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1   DC VOLTAGE SOURCE #2 3 0.00391 0.00389 1.501955 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC VOLT METER 1 7.9 7.9139 0.1264 P P

 

The S/N, P/N, and test number all will be the same. Test and Step Passed would be P or F calculated based on the tolerances. The test name would be the name at the top of the values seen in the initial data file. And each line in the initial data file would correspond to a different step number

0 Kudos
Message 5 of 8
(2,240 Views)

The units need to be taken out. 

0 Kudos
Message 6 of 8
(2,239 Views)

The data you originally posted was:

DC VOLT METER TEST USING STM VOLTAGE SOURCE
P/F VOLTAGE RANGE TEST V0LTAGE DCVM VOLTAGE TOLERANCE
==== ============= ============ ============ =========
+/-200.00 V 7.9000 V 7.9139 V 1.6 %
+/-200.00 V -7.9000 V -7.9204 V 1.6 %

 

Can I assume that you want to delete the first three lines?  Now, how do the remaining strings parse (in terms of the spreadsheet you just posted)?  

S/N Debug Date Time Operator P/N Test # Test Name Step # Expected Received Tolerance Step Passed? Test Passed?
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC VOLT METER 1 7.9 7.9075 0.1264 P P
11001 F 6/1/2017 ######## E10001 PH95229228X 1 DC VOLT METER 2 -0.126 -0.126 -0.00164 P P

Can I assume that "+/-" can be ignored?  Is "200" one of these numbers, or can it also be ignored?  I'm assuming we can ignore the "V"s and the "%".  What about 7.9000, 7.9139, and 1.6?  The first two look like maybe "expected" and "received".

 

You are in the best position to know what part of the data are relevant to you.  In my earlier response, I suggested how you could go about analyzing these data.  I'll ask again, have you ever worked with Strings, in any Programming language?  If the answer is "No", you need to spend some time with learning something about string processing, and you might as well start with LabVIEW (as you will be using the LabVIEW String Functions).  Take the relevant part of the LabVIEW Training, and start figuring out what to Keep and what to Throw Away in your data strings.

 

Bob Schor   

0 Kudos
Message 7 of 8
(2,234 Views)

I have quite a bit of string experience with many different programming languages, but all syntax. Have played with some ladder programming but nothing along these lines. So in the orginal data all that needs to be kept is the "DC VOLT METER TEST USING STM VOLTAGE SOURCE", then the last three values without the units (ie 7.9000, 7.9139, and 1.6). So yes the +/-200.00 can be ignored. I have gotten the data file into a array of strings that contain the each line as a whole. Im not looking at parsing through these. I have been trying to use match pattern to do so inside a for loop. Below is the two methods I have been using to sort the data into an array of each line as strings. This vi I am using the top method because it seems to be more compatible with the match case.

lbv1.PNG

0 Kudos
Message 8 of 8
(2,216 Views)