Forum Discussion

Pandadev's avatar
Pandadev
Post Prodigy
6 years ago
Solved

Importing Pdf Table from web url using Python , but it is not stored as dataframe in PowerBI

Hi I am trying to import a pdf table to PowerBI. from - https://www.caas.gov.sg/docs/default-source/pdf/singapore-registered-aircraft-engine-nos---apr-2020d1324ca0a72f4d42bd40c25673b42c82.pdf

I am new to both PowerBI and Python , but from research managed to get this code working

 

import tabula
file = "https://www.caas.gov.sg/docs/default-source/pdf/singapore-registered-aircraft-engine-nos---apr-2020d1324ca0a72f4d42bd40c25673b42c82.pdf"
tables = tabula.read_pdf(file, pages = "all", multiple_tables = True)

 

but for some reason it is not showing as a table in PowerBI , even though no errors are reported

7 Replies

    • Pandadev's avatar
      Pandadev
      Post Prodigy

      Thanks , yes that works fine for this pdf , but when I import a pdf where I only want certain tables , how can I merge all those selected tables to one table. all the selected tables will have the same structure , column order etc.

      • V-lianl-msft's avatar
        V-lianl-msft
        Community Support

        Hi Pandadev ,

         

        Based on your description. You can get this PDF file using the web connector.

        let
            Source = Pdf.Tables(Web.Contents("https://www.caas.gov.sg/docs/default-source/pdf/singapore-registered-aircraft-engine-nos---apr-2020d1324ca0a72f4d42bd40c25673b42c82.pdf-is-not/td-p/1121450"), [Implementation="1.1"]),
            Table001 = Source{[Id="Table001"]}[Data],
            #"Promoted Headers" = Table.PromoteHeaders(Table001, [PromoteAllScalars=true]),
            #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"NO.", Int64.Type}, {"TYPE", type text}, {"REG", type text}, {"OPERATOR", type text}, {"ENGINE TYPE", type text}})
        in
            #"Changed Type"

        Use append queries to append more tables.

         

        Best Regards,
        Liang
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.