feat: Add UnstructuredTSVLoader (#7367)

### Summary

Adds an `UnstructuredTSVLoader` for TSV files. Also updates the doc
strings for `UnstructuredCSV` and `UnstructuredExcel` loaders.

### Testing

```python
from langchain.document_loaders.tsv import UnstructuredTSVLoader

loader = UnstructuredTSVLoader(
    file_path="example_data/mlb_teams_2012.csv", mode="elements"
)
docs = loader.load()
```
This commit is contained in:
Matt Robinson
2023-07-10 03:07:10 -04:00
committed by GitHub
parent 490f4a9ff0
commit bcab894f4e
8 changed files with 273 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
import os
from pathlib import Path
from langchain.document_loaders import UnstructuredTSVLoader
EXAMPLE_DIRECTORY = file_path = Path(__file__).parent.parent / "examples"
def test_unstructured_tsv_loader() -> None:
"""Test unstructured loader."""
file_path = os.path.join(EXAMPLE_DIRECTORY, "stanley-cups.tsv")
loader = UnstructuredTSVLoader(str(file_path))
docs = loader.load()
assert len(docs) == 1

View File

@@ -0,0 +1,5 @@
Stanley Cups
Team Location Stanley Cups
Blues STL 1
Flyers PHI 2
Maple Leafs TOR 13
1 Stanley Cups
2 Team Location Stanley Cups
3 Blues STL 1
4 Flyers PHI 2
5 Maple Leafs TOR 13