LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the number from a certain column in an running .CSV file

Solved!
Go to solution

Dear Sirs:

I am a new guy for LabView & struggling for one question. Here is my problem, 

I have a .CSV as attached file "Collected data.csv".

I have to capture the value real-time from channel 320 as a feedback to control my device ON or OFF.

New data is coming every 10secs & the .csv file is updated. 

So I have to make sure the newest data has been captured.

I have tried several built-in functions in LabVIEW but always failed. 

Kindly help.

Thanks in advance

 

eevisi

Download All
0 Kudos
Message 1 of 80
(3,322 Views)

Where is the data coming from?

 

Using a file to transfer continuously changing data from one program to another is not a very robust method.  What happens if the writing program has the file open and locked when you want to read it?

What happens if LabVIEW has the file open and locked (the Read only setting might help here) when the other program wants to open it up to add to it.

 

When you say "I have tried several built-in functions in LabVIEW but always failed", it helps if you post at least one of those failed attempts so we can we what you did and give suggestions on how to correct it!

Message 2 of 80
(3,278 Views)

Hi RavensFan:

The data comes from the Agilent DAQ 34970A, which perform the thermoCoupling test.

While the 34970A running, the data will be collected into a tmp file which been re-written after every channel scan (about 30secs)

The tmp file will be re-named by the time of last updated.

(In fact, it's my next task to find out how to copy the tmp file & paste on somewhere else, then no one will be impacted while the LabVIEW program is running) .

Pls see the screenshot below, the number 22.707 is the last updated number which I need to use for system control afterward.

 

Thanks in advance

 

1.JPG2.JPG

0 Kudos
Message 3 of 80
(3,263 Views)

I have to echo Ravens Fan's concerns as two programs trying to access one file simultaneously rarely works reliably. Due to Windows operating system's file protections if one program has a file open for writing, that file access is locked so no other program can access it. This makes sense when you think about it, because if one program is changing a file. The second program should no be allowed to read the file until it is updated, so the "reader" always has the most current information. 

 

I am not saying it can't be done but you are going to have to be prepared to handle the file access violation error that could occur using this method. 

 

But in general all you need to do is read the entire .CSV file into an array

(use "Read Delimited Spreadsheet.vi" and set the Delimiter to a ",") 

 

Then index out the row and/or column that contains the value(s) you need.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 80
(3,258 Views)

 



@eevisi.chen wrote:

Hi RavensFan:

The data comes from the Agilent DAQ 34970A, which perform the thermoCoupling test.

While the 34970A running, the data will be collected into a tmp file which been re-written after every channel scan (about 30secs)

The tmp file will be re-named by the time of last updated.

(In fact, it's my next task to find out how to copy the tmp file & paste on somewhere else, then no one will be impacted while the LabVIEW program is running) .

Pls see the screenshot below, the number 22.707 is the last updated number which I need to use for system control afterward.

 

Thanks in advance

 

1.JPG2.JPG


 

OMG! If you are using a data logger WHY are you using this roundabout method?

ARE YOU STILL USING Benchlink to collect data with your 34970A?

 

There are "Plug and Play" LabVIEW drivers for the HP/Agilent/Keysite 34970A that you can use to make one program that will do everything you need.

 

I have been using this instrument for over a decade and can probably answer any questions you might have.

 

========================
=== Engineer Ambiguously ===
========================
Message 5 of 80
(3,252 Views)

Use LV to ask the instrument for the value and have LV log it to file for later retrieval. 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 80
(3,249 Views)

Hi RTSLVU:

I fully agree both Ravens Fans & your concern & appreciate your comment.

That's why I plan to copy the original .csv file periodically & paste to somewhere else then deal with it there.

But it would be my 2nd task...

The 1st task I have to solve is, how to grab the correct number at correct position then use it as a feedback to control my system.

In fact, you just inspire me. thank a lot!!

 

eevisi

 

 

 

0 Kudos
Message 7 of 80
(3,241 Views)

You read the whole file and the extract the last line. Read from spreadsheet file and Delete from Array would be the easiest way to do that.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 80
(3,236 Views)

@eevisi.chen wrote:

Hi RTSLVU:

I fully agree both Ravens Fans & your concern & appreciate your comment.

That's why I plan to copy the original .csv file periodically & paste to somewhere else then deal with it there.

But it would be my 2nd task...

The 1st task I have to solve is, how to grab the correct number at correct position then use it as a feedback to control my system.

In fact, you just inspire me. thank a lot!!

 

eevisi

 

 

 


Why are you still trying to use this round about method? 

 

Using LabVIEW and the 34970A drivers you have everything you need to take a measurement, save the data to a file, and make program control decisions all in one program without having to deal with all these temporary files, opening and closing, access violations, etc...

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 80
(3,233 Views)

Thank you, Yamaeda san.

Considered the difficulty which seniors mentioned,

I may follow their advice to re-start the study about the 34970A Instrument driver 

Many thanks for your kindness & guide.

 

eevisi

 

 

0 Kudos
Message 10 of 80
(3,208 Views)