LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel: New file name for every code run

Solved!
Go to solution

Hey guys,

 

Got a new issue I could use some help with. Still relatively new with LabVIEW so bear with me.

 

I've currently got a setup which uses a DAQ to monitor data from a Level Sensor and I'm exporting this monitored data in real-time to an excel file. The code works great if I create a new excel file each time I input a new Report File Path per run but I would like to make this automatic.

I was trying to get the name of the excel file to be the current date/time as soon as the code starts running and to auto save as soon as the code stops but I can't get it to do this. Each time I run the code with my structured file path and concatenated strings to build the name of the file per run, it just doesn't use the name and instead defaults to Book1, 2, 3 etc. and it also doesn't auto save anymore. Clearly I'm doing something wrong here.

I've attached my VIs (current and older versions) and any advice is welcome. I'm not trying to create new worksheets inside of the same book each time either. I just need a new file per run with the name of the file being the date/time when the code runs and automatically saving when the code stops running.

Thanks in advance for the input.

 

Kind regards,

PDB

Download All
0 Kudos
Message 1 of 6
(243 Views)
Solution
Accepted by topic author PDBSteenhuisen

My bad...

 

Again, I figured it out on my own.

 

It was mainly a string error in the path since the date/time registered with / and : but I've changed it to - and made the excel file use the first value of time when the code has started as the name for the file by keeping the time outside of the while loop and then feeding it into the path. I should do the same for the date but I don't see this running overnight yet but I'll do the same for it eventually.

Also, my snippet removed the while loop but its the same as before with only one shift register for the array.

Hopefully my solution is useful to anybody else!

 

 

0 Kudos
Message 2 of 6
(200 Views)

Why do you have data flowing from right-to-left, i.e. backwards, in your code?  [Or at least that's how it looks to me].

 

Bob Schor

0 Kudos
Message 3 of 6
(156 Views)

Mostly just aesthetic choices but there's only two data wires going "backwards" at the moment - the full sensor batch string array that exports the real-time data to Excel and the string output of the date/time because of file path name reasons.

 

PDB 

0 Kudos
Message 4 of 6
(146 Views)

Just a suggestion -- If there really is a block of code that occupies a lot of space on the Block Diagram but has a few inputs (yours seems to have 2) and a few outputs (yours seems to have 1), that's a great "opportunity" to encapulate all that code in a sub-VI (which occupies a 32x32 pixel area, and with 2 inputs and 1 output, can be realized in a 16 x 32 box, with a Label or VI Icon to say what it does (e.g. "Bld Hdr").  This is called (by me, anyways) "Hiding the Messy Details").

 

Before I started to learn/use LabVIEW, I had been programming in Text-based languages (Fortran, Pascal, Matlab, Mathematica), so the basic concepts of coding were familiar.  My second LabVIEW book was "The LabVIEW Style Book", which made my LabVIEW programs understandable to myself a month later, and "explainable" to my colleagues.  Sometimes you don't need to see the messy detail.

 

Bob Schor

0 Kudos
Message 5 of 6
(110 Views)

Hey again,

 

My bad for the late response.

 

Yeah, I get that. My coding style is very unconventional still but I'll get there eventually.

 

Thanks for the recommendations. Will try to learn from it when I've got a bit more time on my hands.

 

PDB

0 Kudos
Message 6 of 6
(26 Views)