mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-14 05:56:40 +00:00
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
This commit is contained in:
15
tests/integration_tests/document_loaders/test_csv_loader.py
Normal file
15
tests/integration_tests/document_loaders/test_csv_loader.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
5
tests/integration_tests/examples/stanley-cups.csv
Normal file
5
tests/integration_tests/examples/stanley-cups.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
Stanley Cups,,
|
||||
Team,Location,Stanley Cups
|
||||
Blues,STL,1
|
||||
Flyers,PHI,2
|
||||
Maple Leafs,TOR,13
|
|
Reference in New Issue
Block a user