title: Join tables separated by a page break in Camelot
body: <p>how can a table that spanned across 2 pages can be joined? I  have a  monthly invoice pdf  with  multiple tables and some  span across  pages,  I want to automate   pdf  data  extraction to  be  dumped to  a  CSV. I've been looking  for  a way  and I can join the table manually  but  is there a way to do this atomized?  I  cant  share  the original   PDF  since is  sensitive info, but  my tables  have a  distinctive   first  row  and  last row</p>
  <p>I think there should be  a  way  to iterate over  all tables.  Look  for a beginning  row  and  ending  row . If a table does not  have the ending  row and the next table does not have the  beginning row  to merge  those tables but I cant put this in to code yet!  its my  first  time with data frames and  for some  reason I cant  seem to wrap my head a round  how they work.</p>
  <pre><code>pdfdata = camelot.read_pdf('sample.pdf', flavor='lattice', pages='all', encoding='latin-1',flag_size=True )
  
  j2j1=pdfdata[2].df
  j2j2=pdfdata[3].df
  
  frames =[j2j1,j2j2]
  df_keys = pd.concat(frames, keys=['x','y'])
  
  print(df_keys)
        
  </code></pre>
  <p>this is the way  every table look  on PDF, and its  100%  accuracy  on  parsing  report for every table <code>{'accuracy': 100.0, 'whitespace': 3.33, 'order': 1, 'page': 13}</code> as I mentioned  every table starts  with header  and  ends  with  row that starts with  <strong>siteCode</strong>  this is unique  on  every table and its  made up  of 4 digits or 4 digits and a number  i.e. USCA or USCA1.</p>
  <pre><code>Item       | description        | price |  units |  total   |
  1234       | gen. description   | 11.00 |    5   |  55.00   |
  2345       | gen. description   | 9.00  |    4   |  36.00   |
    -
    -
    -
  6789       | gen. description   | 15.00 |   10   | 150.00   |
  siteCode   |                    |       |        | 241.00   |
  </code></pre>
  <p>also a   secondary question  the <code>.export()</code>  function, is there  anyway  to have it  generate only one  csv ?  it generates  a  file per table   over 70 files</p>