05-20-2014 03:35 AM
Hello,
I save my results data from a Vision picture analysis to a CSV File. Works great! Now I want to read the CSV automatically by a server application. I need some hints or tricks to avoid access violations by the server or labview if both programs want to read / write to the file simultaneously.
What I want to do:
The server application read the output file every 30 seconds:
Read the data and delete it afterwards - so no data duplicates should accrue.
Labview writes the data to the file:
If the file does not exists: (deleted) create a new one
If the file is in use: try it next time again (to lose one or two datasets is not important)
I want to use the "write to spreadsheet" function but maybe someone can give me a tip to use this or that to do a better job!
Best regards,
Paul
Solved! Go to Solution.
05-20-2014 07:15 AM
In the File->Advanced palette, there is a nice gem called Check If File Or Folder Exists.vi.
05-20-2014 08:01 AM
I am not sure you want to use Write To Spreadsheet. The functionality is probably too rigid for your application. Use the Open/Write/Close VIs and format using the Array to Spreadsheet String node.
You may want to try a minor variant to your procedure.
A simple <name>_YY-MM-DD-<time>.csv file name format should work for you. You can generate the timestamp string easily enough.
Let us know if you need further help.
05-20-2014 08:11 AM
Hello Crossrulz,
Thank you for your help! I overlooked that VI, works good for initialization and recreation of the file but I am still looking for a method to check if the file is occupied by another program. I found some topics about that stuff using the error code .... let’s see. An alternative could be the tool "Handle v3.51" from Microsoft but you have to use a lot of “string gymnastic”. Not my favorite topic! 😉
Best regards,
Paul
05-21-2014 02:36 AM
Hi Paul,
couldn't you just try it like that (see attachment):
If error 5 occurs the file is already open.
Is that OK for you?
Best regards
Christoph
05-28-2014 01:50 AM
Hi Cristoph,
thank you for your code sample. Using a case structures for checking if the file is occupied by "code 5" works greate! Thank you!