Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
VTom
Regular Visitor

Extract latest csv from folder with multiple gz

Hi,

 

i want to extract from the latest gz file in a folder the csv file and continue with transforming. But it won't work out.... can someone help out?

 

= let
Quelle = Folder.Files("C:\xyz\folder"),
#"Sortierte Zeilen" = Table.Sort(Quelle,{{"Date created", Order.Descending}}),
#"Beibehaltene erste Zeilen" = Table.FirstN(#"Sortierte Zeilen",1)
Decompressed = Binary.Decompress(Source, Compression.GZip),
#"Imported CSV" = Csv.Document(Decompressed,[Delimiter="", Encoding=1252),
in
#"Imported CSV"

 

Thanks

1 REPLY 1
rubayatyasmin
Super User
Super User

Hi, @VTom 

 

you need to add GetBinary = KeptFirstRow{0}[Content], before decompressing. to keep only the first row, which is the latest file. 

 

so your modified code will be something like

 

let
Source = Folder.Files("C:\xyz\folder"),
SortedRows = Table.Sort(Source,{{"Date created", Order.Descending}}),
KeptFirstRow = Table.FirstN(SortedRows,1),
GetBinary = KeptFirstRow{0}[Content],
Decompressed = Binary.Decompress(GetBinary, Compression.GZip),
ImportedCSV = Csv.Document(Decompressed,[Delimiter=",", Encoding=1252])
in
ImportedCSV

 

Also, this tutorial will be helpful. 

 

rubayatyasmin_0-1689517080227.png

 

 


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors