LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to append data from one file to another

Hello,

I am trying to replace one column of numbers in a 2D array with a unique string from another file.

Pos.    Serial    Gain
 2        3252        4
 4        15697      4
 6        15543      4

I want to replace the "4" in the third column with a string obtained from another file, such as;

Serial # 3252 Fuel Cell # arxe-2282
Time and date 09:47   09/08/07
Version 4.0
Serial # 1234 Fuel Cell # arxf-0047
Time and date 09:50   09/08/07
Version 4.0

In this case, I want to replace the "4" in the first row of the top file (after the header) with "arxe-2282" from the file just above.

This means I need to search though the second file (which will have multiple entries) and find the same serial number (in this case "3252") and then write the "arxe-2282" string in place of the "4" in the top file, right next to the "3252" number there.

The search part is proving difficult. I can replace the "4" easy enough, but only if I already know where the "arxe-2282" is in the second file.

Any ideas?

Tay


0 Kudos
Message 1 of 6
(3,022 Views)

May be you can read all the lines from the second file and convert this string into a spreadsheet array. After conversion, search the particular column for the text you are looking. Once found, using the index of the found item, you can index the text with which you want to replace in the first file. Hope that helps!

 

Message 2 of 6
(3,013 Views)

try this.....

the program uses the match pattern and scan from string functions.  And there is still room for improvement.

If you have to do is more often with bigger files, you should create a lookup table first. currently the files is scanned each time ....

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 3 of 6
(2,999 Views)
I'll look into those functions. I am using version 7, and so wasn't able to open your vi. Could you post an image of it?

Tay
0 Kudos
Message 4 of 6
(2,989 Views)
Here is a jpg image of the VI, enjoy!

-Bob

Message Edited by B O B on 09-11-2007 09:52 AM

Message 5 of 6
(2,981 Views)
That has me along my way! Thanks! I had some trouble getting the "scan from string" to output a string, but all is well.

You guys are great!

Tay
0 Kudos
Message 6 of 6
(2,949 Views)