diff --git a/langchain/document_loaders/csv.py b/langchain/document_loaders/csv.py index af98db46..1108730f 100644 --- a/langchain/document_loaders/csv.py +++ b/langchain/document_loaders/csv.py @@ -34,13 +34,13 @@ class CSVLoader(BaseLoader): with open(self.file_path, newline="") as csvfile: csv = DictReader(csvfile, **self.csv_args) # type: ignore - for row in csv: + for i, row in enumerate(csv): docs.append( Document( page_content="\n".join( f"{k.strip()}: {v.strip()}" for k, v in row.items() ), - metadata={"source": self.file_path}, + metadata={"source": self.file_path, "row": i}, ) )