LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Merging data into a single row

Solved!
Go to solution

@Jousepa wrote:

 one row with (date, time, pH, temp, CD, temp).

 


Can you instead give the index of the desired fields? What's the difference between "temp" and "temp"?

0 Kudos
Message 11 of 15
(50 Views)
Solution
Accepted by Jousepa

Here's how you could use a map with the ID as key and the output row as value.

The rows in the original file can be in any order and the output is guaranteed to be sorted by ID.

 

In the full code, you should retain the map between iterations and just add new rows when they arrive.

 

altenbach_0-1770336145841.png

 

Depending how "sane" the input file is, you might need additional checks and error handling)

 

For better debugging, I recommend to generate a test file where the pH and CD values actually differ between rows!

Message 12 of 15
(46 Views)

@altenbach  ha escrito:

@Jousepa wrote:

 one row with (date, time, pH, temp, CD, temp).

 


Can you instead give the index of the desired fields? What's the difference between "temp" and "temp"?


The index are (2 (date), 3 (time), 8 (ID), 9 (ph/CD), 11 (temp1/temp2) ).

 

The temperatures are provided by the pH and conductivity sensors themselves.

 

I guess its to late for this reply, I'll go check the code you just provided me. Thank you very much. 

 

Jousepa

0 Kudos
Message 13 of 15
(33 Views)

@altenbach  ha escrito:

Here's how you could use a map with the ID as key and the output row as value.

The rows in the original file can be in any order and the output is guaranteed to be sorted by ID.

 

In the full code, you should retain the map between iterations and just add new rows when they arrive.

 

altenbach_0-1770336145841.png

 

Depending how "sane" the input file is, you might need additional checks and error handling)

 

For better debugging, I recommend to generate a test file where the pH and CD values actually differ between rows!


I tried the code exactly as it was, adding a while loop, and I’m pretty sure it works just fine because im not doing a real streaming.
Thank you all, you are truly a blessing.

0 Kudos
Message 14 of 15
(28 Views)

@Jousepa wrote:
I tried the code exactly as it was, adding a while loop, and I’m pretty sure it works just fine because im not doing a real streaming.

Here's how I would add a while loop, keeping the map intact (no need to scan for duplicates, automatically sorted by ID, etc.). I also left some diagram comments for further development. For example, you could cache the map to file and reload on next program start.

 

Note that the file is only scanned on demand. It if should occur at regular intervals, you can add a reasonable timeout to the main event case..

 

altenbach_0-1770394149658.png

 

 

 

0 Kudos
Message 15 of 15
(12 Views)