07-06-2017 03:41 PM - edited 07-06-2017 03:43 PM
I am attempting to build a VI that opens the last 5 production days of data in order to create a "real time" history graph that compares each day.
Production days are Monday 7 am through Saturday 7 am. Shifts are 1= 7-3, 2= 3-11, and 3=11-7.
I already built a VI that saves a shifts worth of OEE/Production values into a .txt file with a date and what shift it was. Example: dd/mm/yyyy_shift#.txt (I am open to changing that format).
I would like this VI to open all of the files for the previous 5 production days. I am having issues such as weekends or days when no production was planned (no file exists for that day).
Thank you,
Solved! Go to Solution.
07-06-2017 03:53 PM
I put this together in just a couple hours so it is a little messy. But it's the main idea for the data saving VI. From here I would like the Data Open VI to take the date here I changed it to %j for testing but %d%m%Y is what that normally is. Again thanks for looking into this.
07-06-2017 03:58 PM
Hi engineer,
I am having issues such as weekends or days when no production was planned (no file exists for that day).
What kind of issues?
When you know it is a weekend you only need to choose the next day. And you need to handle errors if the FileOpen function outputs them…
Other option:
Use ListFolder to get a list of all files fitting to your filename convention. Then parse the filenames and choose those ones fitting your "5 last days" requirement…
dd/mm/yyyy_shift#.txt (I am open to changing that format).
I recommend not to put slashes in filenames. I also recommend to format the date like YYYYMMDD for easier sorting of the files…
07-06-2017 04:19 PM
Hi Cory,
Once you have your list of files, you want the 5 most recent days. What I would do, is keep an array of the most recent days, and once you try to add the 6th one, stop looking through files. This assumes your array is sorted. I use a filename format like "YYYYMMDD_Filename.txt" most of the time, so that windows can easily organize by date. Here is an example to get you going:
07-07-2017 09:18 AM
Hey Gregoryj,
Thank you for start on the file system. I do not want to manually input the file names of the most recent days. What would be a way to implement an array of saved files? I tried making that in the Data Save VI, but again I come across the issue of defining the previous 5 production days and whether or not all shifts were producing.
Thank you,
Cory
07-07-2017 09:36 AM
Look for the List Folder function.