langchain/tests/integration_tests/document_loaders/test_csv_loader.py
Matt Robinson 11fec7d4d1
feat: Add UnstructuredCSVLoader for CSV files (#5844)
### Summary

Adds an `UnstructuredCSVLoader` for loading CSVs. One advantage of using
`UnstructuredCSVLoader` relative to the standard `CSVLoader` is that if
you use `UnstructuredCSVLoader` in `"elements"` mode, an HTML
representation of the table will be available in the metadata.

#### Who can review?

@hwchase17
 @eyurtsev
2023-06-07 19:18:01 -07:00

16 lines
425 B
Python

import os
from pathlib import Path
from langchain.document_loaders import UnstructuredCSVLoader
EXAMPLE_DIRECTORY = file_path = Path(__file__).parent.parent / "examples"
def test_unstructured_csv_loader() -> None:
"""Test unstructured loader."""
file_path = os.path.join(EXAMPLE_DIRECTORY, "stanley-cups.csv")
loader = UnstructuredCSVLoader(str(file_path))
docs = loader.load()
assert len(docs) == 1