Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get the extension from a filepath

I need to test the extension of the imported file as to if it is CSV or XLSX

I am trying

FP = Text.AfterDelimiter([Path], ".", {0, RelativePosition.FromEnd}),
let 
   FilePath = Excel.CurrentWorkbook(){[Name="fp"]}[Content]{0}[TheFilePath],
   FP = Text.AfterDelimiter([FilePath], ".", {0, RelativePosition.FromEnd}),
   Source = Excel.Workbook(File.Contents(FilePath))
in Source

But I get the error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

I did try

 FP = Text.AfterDelimiter(_[FilePath], ".", {0, RelativePosition.FromEnd})

This did not correct the issue

>Solution :

How about this, which finds the part after the last period?

let  FilePath = Excel.CurrentWorkbook(){[Name="fp"]}[Content]{0}[TheFilePath],
Extension=List.Last(Text.Split(FilePath,"."))
in Extension

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading