LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Properly close file from Write Delimited Spreadsheet ?

My issue is simple, I am writing results onto PC using Write Delimited Spreadsheet, and it won't work with Close, which need a refnum as the path while the Write Delimited Spreadsheet output a real path.

 

I am aware that the opposite feature exists, as there is a function called refnum to path, but how to do the opposite, path to refnum to proper close the file after written by Write Delimited Spreadsheet?

 

Or is there a different way to close it?

 

Thank you all!

0 Kudos
Message 1 of 14
(2,950 Views)

The function "write delimited spreadsheet" is high level and opens and closes the file with every call. (You can look inside).

 

If performance is important, keep the file open and do low-level stuff until done.

0 Kudos
Message 2 of 14
(2,936 Views)

Hi altenbach,

 

Thank you so much, I've looked several levels inside, and you are correct that it does close the file internally.

 

My confusion is, as I am writing files to my local OneDrive folder, other direct write operations with clear "close" code will immediate upload to the OneDrive cloud except the ones written by the delimited write, so that's why I doubt it didn't properly close the file thus windows cannot operate on it.

 

I guess it has something to do with complex hierarchies in the windows operating system.

0 Kudos
Message 3 of 14
(2,861 Views)

@princelog wrote:

I guess it has something to do with complex hierarchies in the windows operating system.


You have local file caching and Onedrive background syncing and these things are partially out of your control. To ensure that the data is on disk and not buffered somewhere, you can use lower level IO as already mentioned. Especially the flush file function will allow you to sync data to disk, without even having to close the file. How often do you update the file?

0 Kudos
Message 4 of 14
(2,857 Views)

Thank you very much! I never used the flush function, I will learn it more.

 

I will have five separate folders, in each folder I'll created about 10 files within 1 minute, and 2 minutes later do the same in the next folder, thus for each folder 10 files will be written every 10 minutes.

0 Kudos
Message 5 of 14
(2,855 Views)

Your observation that OneDrive is interfering with LabVIEW suggests that you consider turning off OneDrive while running your LabVIEW program.  It seems to be entirely too "aggressive" in its behavior.  A number of us have disabled OneDrive for interfering with LabVIEW development and running LabVIEW programs to acquire data, control devices, etc. without an Operating System company deciding where and how we manage our data in Real Time.  For keeping our (development) files organized, we have Subversion and GIT, and for safety, there are other (and better, IMHO), options ...

 

Bob Schor

0 Kudos
Message 6 of 14
(2,812 Views)

Hi Bob,

 

Thank you for your reply but you totally got it wrong. My observation is that when I use open file -> write -> close file codes in Labview, I can immediately access the file from the operating system, i.e. windows. And when I use Write to Delimited Spreadsheet [WTDS], although it's internal function (subVI) include a Close File code, it doesn't really work for some reason, and the operating system cannot immediate access that particular file until the handle is eliminated by some means, usually either by writing to a new delimited spreadsheet, or by stopping the VI. And then, I am coincidently writing to OneDrive folder, and since windows cannot access the particular one written by [WTDS], OneDrive cannot access it, all other files is immediately uploaded to the cloud but the one written by [WTDS], so I'd say for some reason the internal Close File doesn't really work as good as Close File command.

0 Kudos
Message 7 of 14
(2,781 Views)

A more detailed description of the problem was updated in the thread, if you have any idea, please shoot, thanks!

Message 8 of 14
(2,779 Views)

I have the same issue. The Delimited File can be accessed in my C:\ drive, but "Delimited File" will not sync to OneDrive nor Google Drive until I quit Labview program. Therefore, all other colleagues could not see the data file in the cloud (If I haven't quit Labview program yet).

 

Anyone out there if you have solution to programmatically close Delimited File, please help.

0 Kudos
Message 9 of 14
(2,211 Views)

Hi, I'm glad my issue and my own solution will be able to help you, not those who only show their ignorance of the true needs.

 

I stop using Write to Delimited and read the help on that function, and the last line of the help says: "

 

Write Delimited Spreadsheet Details

 

When you use this VI to write the data, the VI opens or creates the file before writing to it and closes it afterwards. You can use this VI to create a text file readable by most spreadsheet applications. This VI calls the Array To Spreadsheet String function to convert the data."

 

This help tell us two things:

 

1. the Write to Delimited function should close the file afterwards, but it doesn't in practical applications, so this is also the reason I try to remind the developer about this bug.

 

2. It is done through a more basic Array to Spreadsheet String function, basic means it is more reliable.

 

My solutions is to use "Array to Spreadsheet String" + "Write to Text File" + "Close File" to replace previously "Write to Delimited Spreadsheet" + "Write to Text File" + "Close File", and the solution on my computer and system works well, OneDrive is able to read it real-time just like other files.

 

princelog_0-1697253932858.png

(This is what cause the issue)

 

princelog_1-1697253954255.png

(This is what resolved the issue)

 

Don't forget to post if this solution works for you too.

Message 10 of 14
(2,202 Views)