Reads and parses documents from a CSV-style text file
(csv_file_path, site)
| 30 | |
| 31 | |
| 32 | def get_documents_from_csv(csv_file_path, site): |
| 33 | """Reads and parses documents from a CSV-style text file""" |
| 34 | documents = [] |
| 35 | with open(csv_file_path, encoding="utf-8") as file: |
| 36 | for line in file: |
| 37 | if line.strip(): |
| 38 | try: |
| 39 | docs = documentsFromCSVLine(line, site) |
| 40 | documents.extend(docs) |
| 41 | except ValueError as e: |
| 42 | print(f"Skipping row due to error: {e!s}") |
| 43 | return documents |
| 44 | |
| 45 | |
| 46 | async def upload_documents_to_database(documents: list[dict[str, Any]], database: str | None = None): |
no outgoing calls
no test coverage detected