Back to Docling

Conversion of CSV files

docs/examples/backend_csv.ipynb

2.92.02.5 KB
Original Source

Conversion of CSV files

This example shows how to convert CSV files to a structured Docling Document.

  • Multiple delimiters are supported: , ; | [tab]
  • Additional CSV dialect settings are detected automatically (e.g. quotes, line separator, escape character)

Example Code

python
from pathlib import Path

from docling.document_converter import DocumentConverter

# Convert CSV to Docling document
converter = DocumentConverter()
result = converter.convert(Path("../../tests/data/csv/csv-comma.csv"))
output = result.document.export_to_markdown()

This code generates the following output:

IndexCustomer IdFirst NameLast NameCompanyCityCountryPhone 1Phone 2EmailSubscription DateWebsite
1DD37Cf93aecA6DcSherylBaxterRasmussen GroupEast LeonardChile229.077.5154397.884.0519x718[email protected]2020-08-24http://www.stephenson.com/
21Ef7b82A4CAAD10PrestonLozano, DrVega-GentryEast JimmychesterDjibouti5153435776686-620-1820x944[email protected]2021-04-23http://www.hobbs.com/
36F94879bDAfE5a6RoyBerryMurillo-PerryIsabelboroughAntigua and Barbuda+1-539-402-0259(496)978-3969x58947[email protected]2020-03-25http://www.lawrence.com/
45Cef8BFA16c5e3cLindaOlsenDominguez, Mcmillan and DonovanBensonviewDominican Republic001-808-617-6467x12895+1-813-324-8756[email protected]2020-06-02http://www.good-lyons.com/
5053d585Ab6b3159JoannaBenderMartin, Lang and AndradeWest PriscillaSlovakia (Slovak Republic)001-234-203-0635x76146001-199-446-3860x3486[email protected]2021-04-17https://goodwin-ingram.com/