mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
11fec7d4d1
### 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
16 lines
425 B
Python
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
|