Verify if a daily file has been created

phantom
Sat, 11 Mar 2023 09:51:33 +0000
New to Julia

Suppose you have a series of data files that are added daily and named in the following format.

folder/name-01-01-23.csv
folder/name -01-02-23.csv
.
.
.
folder/name-03-10-23.csv

What is the best way to verify if the daily file was created? I wasn’t sure how to get the DateTime information interpolated into the file query given format of the filename so my current approach is something like

julia> cdate = Date(Dates.now())
2023-03-11

julia> dt = split(string(cdate),"-")
3-element Vector{SubString{String}}:
 "2023"
 "03"
 "11"

isfile("folder/name-$(dt[2])-$(dt[3])-$(dt[1][3:4]).csv")

This works but I was just wondering if this was the best approach? The more I browse the posts on this site the more I realize there are generally much smarter ways of doing things.

7 posts - 5 participants