{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TSV\n", "\n", ">A [tab-separated values (TSV)](https://en.wikipedia.org/wiki/Tab-separated_values) file is a simple, text-based file format for storing tabular data.[3] Records are separated by newlines, and values within a record are separated by tab characters." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `UnstructuredTSVLoader`\n", "\n", "You can also load the table using the `UnstructuredTSVLoader`. One advantage of using `UnstructuredTSVLoader` is that if you use it in `\"elements\"` mode, an HTML representation of the table will be available in the metadata." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from langchain.document_loaders.tsv import UnstructuredTSVLoader" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "loader = UnstructuredTSVLoader(\n", " file_path=\"example_data/mlb_teams_2012.csv\", mode=\"elements\"\n", ")\n", "docs = loader.load()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Nationals, 81.34, 98
Reds, 82.20, 97
Yankees, 197.96, 95
Giants, 117.62, 94
Braves, 83.31, 94
Athletics, 55.37, 94
Rangers, 120.51, 93
Orioles, 81.43, 93
Rays, 64.17, 90
Angels, 154.49, 89
Tigers, 132.30, 88
Cardinals, 110.30, 88
Dodgers, 95.14, 86
White Sox, 96.92, 85
Brewers, 97.65, 83
Phillies, 174.54, 81
Diamondbacks, 74.28, 81
Pirates, 63.43, 79
Padres, 55.24, 76
Mariners, 81.97, 75
Mets, 93.35, 74
Blue Jays, 75.48, 73
Royals, 60.91, 72
Marlins, 118.07, 69
Red Sox, 173.18, 69
Indians, 78.43, 68
Twins, 94.08, 66
Rockies, 78.06, 64
Cubs, 88.19, 61
Astros, 60.65, 55
\n" ] } ], "source": [ "print(docs[0].metadata[\"text_as_html\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.13" } }, "nbformat": 4, "nbformat_minor": 4 }