code: def main():
      import sys
  
      pdf_file = str(sys.argv[1])
      flavor = str(sys.argv[2])
      line_scale = int(sys.argv[3])
  
      pages = "all"
      if len(sys.argv) > 4:
          pages = str(sys.argv[4])
  
      table_areas = None
      if len(sys.argv) > 5:
          table_areas = sys.argv[5].split(";")
  
      if flavor == "lattice":
          tables = camelot.read_pdf(
              pdf_file,
              pages=pages,
              flavor=flavor,
              line_scale=line_scale,
          )
      else:
          tables = camelot.read_pdf(
              pdf_file,
              pages=pages,
              flavor=flavor,
              table_areas=table_areas,
          )
  
      if len(tables) == 0:
          # print('No tables detected ', tables)
          print(json.dumps([]))
          sys.exit(0)
  
      output = []
      distinct_pages = set(list(map(lambda x: x.page, tables)))
      # print('Pages with tables: ', distinct_pages)
      for page in distinct_pages:
          tables_in_page = list(
              filter(lambda x: x.page == page, tables)
          )
          tables_data = list(
              map(
                  lambda x: extract_table_data(x, flavor),
                  tables_in_page,
              )
          )
          tables_data = list(filter(lambda x: x != None, tables_data))
          output.append(create_page_data(page, tables_data))
  
      print(json.dumps(output))
      # print(output)
      sys.exit(0)
  
file_path: doc-parsr/server/assets/TableDetectionScript.py
imports: import camelot
  import json
label_desc: Use image node_id 15 for calling a global function with example usage: main() without return types