usql
usql copied to clipboard
Check if file exists at the location.
Hi, Is there a way to check if the file from which we will be extracting values exists at that location?
IF File.Exists("file_location")
THEN
//Proceed further, extract values from the file using Extractor.
ELSE
// Other things to do
Something like this?
IF (FILE.EXISTS("/Samples/Data/SearchLog.tsv"))
THEN
@searchlog =
EXTRACT UserId int,
Start DateTime,
Region string,
Query string,
Duration int?,
Urls string,
ClickedUrls string
FROM "/Samples/Data/SearchLog.tsv"
USING Extractors.Tsv();
ELSE
@searchlog =
SELECT * FROM
( VALUES
("Not Exist")
) AS T(col1);
END;
OUTPUT @searchlog
TO @"/Samples/Data/Test.txt"
USING Outputters.Csv();
dagiro, I tried the same, but it does not work. It gives compile time error ,"File not found".
The above should work. Can you provide me with a repro? Also did you try it locally or on a cluster account?
MikeRys, I tried it locally.