Spaces:
Running
Running
File size: 550 Bytes
d2a63cc e4316f1 d2a63cc 0b9d8c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from typing import Any, Dict, List
import pandas as pd
from graphgen.bases.base_reader import BaseReader
class CSVReader(BaseReader):
def read(self, file_path: str) -> List[Dict[str, Any]]:
df = pd.read_csv(file_path)
for _, row in df.iterrows():
if "type" in row and row["type"] == "text" and self.text_column not in row:
raise ValueError(
f"Missing '{self.text_column}' in document: {row.to_dict()}"
)
return self.filter(df.to_dict(orient="records"))
|