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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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 Solution Authors