From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-07-2017 03:01 PM
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!!!
06-07-2017 04:51 PM - edited 06-07-2017 04:51 PM
Use the Read Delimited Spreadsheet VI to load the file into an array.
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
06-07-2017 04:58 PM
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).
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
06-07-2017 06:20 PM
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
06-07-2017 08:43 PM
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
06-07-2017 08:44 PM
The units need to be taken out.
06-07-2017 08:55 PM
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
06-09-2017 08:02 AM
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.