From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automated File path change during operation

Solved!
Go to solution

Hello!

    At work we have a device that we are constantly monitoring and logging temperature of. 

Is there a simple way that I can have the path change automatically based on date?

Ideally it will log all day and once the date has changed, it will create a new folder can start then depositing all the data into that folder

Any thoughts or opinions are appreciated 

0 Kudos
Message 1 of 11
(1,526 Views)
Solution
Accepted by topic author Ziadeh

Of course, simply build a string with all dates, times, labels, etc. in it, and build a path from it.

 

For example (there are dozens of ways to do this):

Build Path.png

 

You can use Create Folder and\or Check If File Or Folder Exists.vi to optionally make the path hierarchy.

Message 2 of 11
(1,496 Views)
Message 3 of 11
(1,490 Views)

wiebe@CARYA wrote:

You can use Create Folder and\or Check If File Or Folder Exists.vi to optionally make the path hierarchy.


I tend to just try to create the folder unconditionally.  If it already exists, you will get error 10 ("duplicate path"), which you can just ignore with the Clear Errors VI (has an input for only clearing specific errors).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 11
(1,479 Views)

@crossrulz wrote:

wiebe@CARYA wrote:

You can use Create Folder and\or Check If File Or Folder Exists.vi to optionally make the path hierarchy.


I tend to just try to create the folder unconditionally.  If it already exists, you will get error 10 ("duplicate path"), which you can just ignore with the Clear Errors VI (has an input for only clearing specific errors).


At some point, there was no way to create multiple folders at one, so if for c:\a\b\c, b and c needed to be created, it had to be done in a loop.

 

It's been a while, and I forgot the details. I think at some point the function started doing that.

 

0 Kudos
Message 5 of 11
(1,468 Views)

wiebe@CARYA wrote:

At some point, there was no way to create multiple folders at one, so if for c:\a\b\c, b and c needed to be created, it had to be done in a loop.

 

It's been a while, and I forgot the details. I think at some point the function started doing that.


That is what I have gathered based on OpenG's version of Create Folder.  But it has been quite a while that I have been using the primitive for creating "deep" directories in the single call.  I just verified that it works that way with LabVIEW 8.2.1.

 

Now just don't try to create a file in a folder that does not exist.  That will still throw an error.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 11
(1,463 Views)

wiebe@CARYA wrote:

@crossrulz wrote:

wiebe@CARYA wrote:

You can use Create Folder and\or Check If File Or Folder Exists.vi to optionally make the path hierarchy.


I tend to just try to create the folder unconditionally.  If it already exists, you will get error 10 ("duplicate path"), which you can just ignore with the Clear Errors VI (has an input for only clearing specific errors).


At some point, there was no way to create multiple folders at one, so if for c:\a\b\c, b and c needed to be created, it had to be done in a loop.

 

It's been a while, and I forgot the details. I think at some point the function started doing that.

 


I seem to remember that as well, but maybe it's the power of suggestion making me susceptible to mass hallucination.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 11
(1,461 Views)

Thank you all so much for the quick responses, I will definitely read that article and try mimicking that sample given

Thanks again!

0 Kudos
Message 8 of 11
(1,447 Views)

Same memory here that "once upon a time", the LabVIEW Create Folder could only create one level at a time.  I remember using the OpenG version specifically *because* it would create as much of the nested folder hierarchy as necessary, whereas the native primitive version would not.

 

A less trustworthy memory makes me think it was still this way in LV 7.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 9 of 11
(1,438 Views)

First off I want to apologize, im sure there are way more pertinent or interesting questions out there than this, but if you would be so kind to help me just a little bit more. Im finding issue on where exactly to implement your suggested portion. Attached is an image of a simplified VI and the result, in this example Im using time instead of an Analog Input with the temperature reading. In my initial post I mentioned dropping the data into separate folders however im perfectly ok with having one folder with multiple CSVs that represent each day. It seems by doing it this way I can have a constant file path and just create the files using your portion. Where I need help is locating where  to put your portion in relation to the while loop that will constantly be running. If it is outside, the path only gets created once, if its inside it will get created every iteration which overwrites the previous iteration. I have tried to put a case structure inside the while loop that compares the initial date to a constantly changing date and if they are not equal then it runs the portion you suggested, however I was struggling to get anything that would accomplish the task. Again I appreciate you help and any suggestions would be great!

Download All
0 Kudos
Message 10 of 11
(1,414 Views)