@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 3.12 kB
Source Map (JSON)
{"version":3,"file":"csv.d.cts","names":["TextLoader","CSVLoaderOptions","CSVLoader","Blob","Promise"],"sources":["../../../src/document_loaders/fs/csv.d.ts"],"sourcesContent":["import { TextLoader } from \"@langchain/classic/document_loaders/fs/text\";\n/**\n * Loads a CSV file into a list of documents.\n * Each document represents one row of the CSV file.\n *\n * When `column` is not specified, each row is converted into a key/value pair\n * with each key/value pair outputted to a new line in the document's pageContent.\n *\n * @example\n * // CSV file:\n * // id,html\n * // 1,<i>Corruption discovered at the core of the Banking Clan!</i>\n * // 2,<i>Corruption discovered at the core of the Banking Clan!</i>\n *\n * const loader = new CSVLoader(\"path/to/file.csv\");\n * const docs = await loader.load();\n *\n * // docs[0].pageContent:\n * // id: 1\n * // html: <i>Corruption discovered at the core of the Banking Clan!</i>\n *\n * When `column` is specified, one document is created for each row, and the\n * value of the specified column is used as the document's pageContent.\n *\n * @example\n * // CSV file:\n * // id,html\n * // 1,<i>Corruption discovered at the core of the Banking Clan!</i>\n * // 2,<i>Corruption discovered at the core of the Banking Clan!</i>\n *\n * const loader = new CSVLoader(\"path/to/file.csv\", \"html\");\n * const docs = await loader.load();\n *\n * // docs[0].pageContent:\n * // <i>Corruption discovered at the core of the Banking Clan!</i>\n */\ntype CSVLoaderOptions = {\n column?: string;\n separator?: string;\n};\n/**\n * A class that extends the TextLoader class. It represents a document\n * loader that loads documents from a CSV file. It has a constructor that\n * takes a `filePathOrBlob` parameter representing the path to the CSV\n * file or a Blob object, and an optional `options` parameter of type\n * `CSVLoaderOptions` or a string representing the column to use as the\n * document's pageContent.\n */\nexport declare class CSVLoader extends TextLoader {\n protected options: CSVLoaderOptions;\n constructor(filePathOrBlob: string | Blob, options?: CSVLoaderOptions | string);\n /**\n * A protected method that parses the raw CSV data and returns an array of\n * strings representing the pageContent of each document. It uses the\n * `dsvFormat` function from the `d3-dsv` module to parse the CSV data. If\n * the `column` option is specified, it checks if the column exists in the\n * CSV file and returns the values of that column as the pageContent. If\n * the `column` option is not specified, it converts each row of the CSV\n * data into key/value pairs and joins them with newline characters.\n * @param raw The raw CSV data to be parsed.\n * @returns An array of strings representing the pageContent of each document.\n */\n protected parse(raw: string): Promise<string[]>;\n}\nexport {};\n//# sourceMappingURL=csv.d.ts.map"],"mappings":";;;;;;AAAyE;AAgDzE;;;;;;AAAiD;;;;;;;;;;;;;;;;;;;;;;;;;;KAZ5CC,gBAAAA;;;;;;;;;;;;cAYgBC,SAAAA,SAAkBF,UAAAA;qBAChBC;uCACkBE,gBAAgBF;;;;;;;;;;;;gCAYvBG"}