02-04-2026 03:38 AM
Hello, in this script I am reading data from the attached Excel file. Basically, the instrument provides the pH value and the conductivity (CD) value in two separate rows. I would like to combine them into a single row, that is, to have one row with (date, time, pH, temp, CD, temp). I filter which values go together using the sample ID. How can I do this?
The Excel file will keep growing with new samples, so I’m looking for a small automation for this.
Thank you.
Solved! Go to Solution.
02-04-2026 04:29 AM - edited 02-04-2026 04:30 AM
Hi Jousepa,
@Jousepa wrote:
I would like to combine them into a single row, that is, to have one row with (date, time, pH, temp, CD, temp). I filter which values go together using the sample ID. How can I do this?
I would do it like this:
Recommendation:
Don't put ALL that stuff into one VI. Separate the different steps into subVIs to keep the code clean and readable.
02-04-2026 10:16 AM
This seems like a trivially simple problem once we know more details.
02-04-2026 11:22 AM
· CSV file
·The instrument is very old and does not expose a COMX serial port. I use the official software, which basically generates this file (.csv) and I manually decide when to save it.
·Since the filename is generated by the software, it changes every time, but I manually force it to overwrite the file by keeping the same name (I know this is quite rudimentary).
·Yes, two rows, one for each sensor.
·It is not corrupted; I think it coincided with the moment when I was operating the instrument and performed a “stop acquisition”.
· The final goal is to combine these data with a pH signal from another instrument and a pressure signal from a pressure indicator, both acquired using an NI DAQ 6001.
· I believe that in the code I added a timestamp-based filter so that the true case is triggered only when there are new data in the file.
· Manually everytime needed, probably once a day.
· Yes. I dont know what happens if there is only one row.
02-04-2026 11:40 AM
Assuming there is a dedicated folder for these output files, It seems it would be easier to let the instrument decide on the filename, then you can use "list folder" to find and parse just the newest file(s). Less work for you! You could even have LabVIEW delete the CSV file once it is processed (or e.g. move it to a backup folder for record keeping if needed). This way only files that are not yet processed will be there.
02-05-2026 12:05 PM
It would be a great help if you could give me some brief guidelines on how to do it. I tried today and it was catastrophic. I’m still very inexperienced with clusters and bundle/unbundle, and I have to admit that my logical/mathematical thinking is quite limited.
02-05-2026 12:47 PM
@Jousepa wrote:
It would be a great help if you could give me some brief guidelines on how to do it. I tried today and it was catastrophic.
This is a long thread with many different suggestions. Without quoting relevant parts of the previous post (as I just did here), it is impossible to tell which post you are replying to and what suggestions you were trying to implement.
02-05-2026 01:41 PM - edited 02-05-2026 01:45 PM
I was referring to @Gerdw reply. I don’t know what’s going on, this is the second time I’ve hit reply and the referenced message doesn’t show up.
02-05-2026 02:33 PM
02-05-2026 03:02 PM
It would be a great help if you could give me some brief guidelines on how to do it. I tried today and it was catastrophic. I’m still very inexperienced with clusters and bundle/unbundle, and I have to admit that my logical/mathematical thinking is quite limited.
🤠
@GerdW ha escrito:
Hi Jousepa,
@Jousepa wrote:
I would like to combine them into a single row, that is, to have one row with (date, time, pH, temp, CD, temp). I filter which values go together using the sample ID. How can I do this?
I would do it like this:
- Filter the CSV data line by line and remove unneeded lines (header, empty lines).
- Parse each line into a cluster of [ID, timestamp, pH, Temp, CD, temp).
- Now you have an array of clusters with ID as first element: sort this array!
- Now entries with same IDs form consecutive array elements...
- Filter this array by combining neighboring elements into a single cluster (of the same datatype).
- Finished: an array of clusters, containing the data for each ID...
Recommendation:
Don't put ALL that stuff into one VI. Separate the different steps into subVIs to keep the code clean and readable.