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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
j_martinho
Helper I
Helper I

Decompress .gz file on Sharepoint to Power BI

Hi!

 

I tried to open the csv from a .gz file allocated in Sharepoint, but I couldn't. Can you help me?

 

I used the function below and the query:

(zip) =>
let
Source =
        Binary.Decompress(
            File.Contents(
                zip),
                Compression.GZip
        ),
#"Imported" =
        Csv.Document(Source,[Delimiter=",", Columns=17, Encoding=65001, QuoteStyle=QuoteStyle.None]),

#"Promoted Headers" = Table.PromoteHeaders(#"Imported", [PromoteAllScalars=true])
in
#"Promoted Headers"

 

Query:

let
    Fonte = SharePoint.Files("https://xxx.sharepoint.com/sites/GSP/", [ApiVersion = 15]),
    #"Linhas Filtradas2" = Table.SelectRows(Fonte, each ([Extension] = ".gz")),
    UnpackGzips = Table.AddColumn(#"Linhas Filtradas2", "Custom", each fnUnpackGzipLinesFromBinary([Folder Path]&[Name])),
    #"Expanded Custom" = Table.ExpandTableColumn(UnpackGzips)
in
    #"Expanded Custom"

 

 

Error:

 

Expression.Error: 1 arguments were passed to a function, which expected between 3 and 4.
Detalhes:
Pattern=
Arguments=[List]

 

1 ACCEPTED SOLUTION

Hi @j_martinho 

 

I used the below code and it worked for me.

 

let
    Source = File.Contents("zip"),
    Decompressed = Binary.Decompress(Source, Compression.GZip),
    #"Imported CSV" = Csv.Document(Decompressed,[Delimiter="|",Encoding=1252]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV")
in
    #"Promoted Headers"

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Regards,
Pranit





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@j_martinho are you getting error on expand step? Can you confirm? or let us know on which step you are getting this error.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

 

erro1.png

 

 

Hi @j_martinho 

 

I used the below code and it worked for me.

 

let
    Source = File.Contents("zip"),
    Decompressed = Binary.Decompress(Source, Compression.GZip),
    #"Imported CSV" = Csv.Document(Decompressed,[Delimiter="|",Encoding=1252]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV")
in
    #"Promoted Headers"

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Regards,
Pranit





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Works! 

I adjusted it so that Power BI downloads the file directly from the web instead of allocating it to Sharepoint. And I used the code from colleague @pranit828. Thank you!

 

let
    Fonte = Web.Contents("https://data.brasil.io/dataset/covid19/caso_full.csv.gz"),
    Decompress = Binary.Decompress(Fonte, Compression.GZip),
    #"CSV Importado" = Csv.Document(Decompress,[Delimiter=",", Columns=17, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Cabeçalhos Promovidos" = Table.PromoteHeaders(#"CSV Importado", [PromoteAllScalars=true]),
    #"Tipo Alterado" = Table.TransformColumnTypes(#"Cabeçalhos Promovidos",{{"city", type text}, {"city_ibge_code", Int64.Type}, {"date", type date}, {"epidemiological_week", Int64.Type}, {"estimated_population_2019", Int64.Type}, {"is_last", type logical}, {"is_repeated", type logical}, {"last_available_confirmed", Int64.Type}, {"last_available_confirmed_per_100k_inhabitants", Int64.Type}, {"last_available_date", type date}, {"last_available_death_rate", Int64.Type}, {"last_available_deaths", Int64.Type}, {"order_for_place", Int64.Type}, {"place_type", type text}, {"state", type text}, {"new_confirmed", Int64.Type}, {"new_deaths", Int64.Type}})
in
    #"Tipo Alterado"

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.