I build a PowerBI file that targets certain set of CSV files.
I have defined a text parameter called ReportDataFolderPath that defines the folder in which the CSV files exist.
I load the data into Csv.Document data source using File.Contents like that:
Source = Csv.Document(File.Contents(ReportDataFolderPath & "\subfolder\filewithdata.csv"),[Delimiter=",", Columns=18, Encoding=65001, QuoteStyle=QuoteStyle.Csv]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), ... the rest is snipped
This works very well when "filewithdata.csv" exists.
However, sometimes the input set of CSV files does not have "filewithdata.csv". This causes template-to-report loading to fail.
I would like to write some sort of check that validates that "filewithdata.csv" is present in the file system before attempting to load it into Csv.Document function. Can someone suggest a way to do it?