Table extract PDF2CSV
Jump to navigation
Jump to search
Astuce pour convertir correctement des tableaux PDF à CSV
import camelot
# Use the 'file_path' variable to specify the path to your PDF
file_path = '/home/noname/Downloads/liste_nationale_internet_310719.pdf'
# Extract tables from the PDF
tables = camelot.read_pdf(file_path, pages='all', flavor='stream')
for i, table in enumerate(tables):
# Convert table to DataFrame
df = table.df
# Define CSV file path, unique for each table
csv_file_path = f'table_{i}.csv'
# Export the DataFrame to a CSV file
df.to_csv(csv_file_path, index=False)