Forum Discussion

diego_martinezn's avatar
diego_martinezn
Frequent Visitor
4 years ago

Losing a column when importing PDF

I'm working with a folder where I have some PDFs, all with the same structure. 

I've developed a function to just upload the files to that folder and automatically apply all transformations and operations to the table. However, I've noticed that power query sometimes recognize the PDF as 2 tables and sometimes as 3 tables. 

My main problem is that when it recognizes 3 tables, it skips one column of data that I need. 

Does this problem have any solution? 

Thank you

10 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    To prevent this, I always add a ColumnCount column that tells me the number of columns in each pdf table.  Then I sort by greatest to least.  This way, your sample file has the maximum number of columns, and when you expand them, you will no longer lose any data!

     

    --Nate

    • diego_martinezn's avatar
      diego_martinezn
      Frequent Visitor

      Hi Anonymous , first of all, thank u for answering.

      Here it's what I've done based on your answer. I add a personalized column where I count the number of columns of each table and sort them, so what I get is three tables sorted as follows: {21columns, 11 columns, 9columns}.

      Then I click on the expand button, and as you said the whole new table has 21 columns but it fills with "nulls" where my missing data should be. 

      I think this procedure is what you meant right? Maybe I'm skipping some steps or don't do it correctly. Let me know 🙂

  • edhans's avatar
    edhans
    Community Champion

    I'm not sure about the PDF connector, but check out your M code in the Advanced editor. The first line for  a CSV import though might look like this:

    = Csv.Document(#"C:\Users\FileList txt",[Delimiter=":", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None])

    It doesn't matter if that file gets a 3rd column added, it will always only read the first two. I remove that.

    = Csv.Document(#"C:\Users\FileList txt",[Delimiter=":", Encoding=1252, QuoteStyle=QuoteStyle.None])

     

    See if your PDF connection has that same setting.

  • Hi diego_martinezn ,

    Could you please share your PDF without any sensitive data here? It will helpful to solve your problem.

    Best Regards,
    Community Support Team _ kalyj