Skip to content

Commit

Permalink
Merge pull request #659 from danielaskdd/cvs_robustness
Browse files Browse the repository at this point in the history
Enhance robustness of CVS processing ,Fix potential CSV parsing issues
  • Loading branch information
LarFii authored Jan 27, 2025
2 parents 3b3e071 + c8d384f commit ba40a8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lightrag/api/lightrag_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ async def index_file(file_path: Union[str, Path]) -> None:
case ".pptx":
if not pm.is_installed("pptx"):
pm.install("pptx")
from pptx import Presentation
from pptx import Presentation # type: ignore

# PowerPoint handling
prs = Presentation(file_path)
Expand Down Expand Up @@ -1216,7 +1216,7 @@ async def insert_file(file: UploadFile = File(...), description: str = Form(None
case ".pptx":
if not pm.is_installed("pptx"):
pm.install("pptx")
from pptx import Presentation
from pptx import Presentation # type: ignore
from io import BytesIO

# Read PPTX from memory
Expand Down Expand Up @@ -1320,7 +1320,7 @@ async def insert_batch(files: List[UploadFile] = File(...)):
case ".pptx":
if not pm.is_installed("pptx"):
pm.install("pptx")
from pptx import Presentation
from pptx import Presentation # type: ignore
from io import BytesIO

pptx_content = await file.read()
Expand Down
4 changes: 2 additions & 2 deletions lightrag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ def truncate_list_by_token_size(list_data: list, key: callable, max_token_size:

def list_of_list_to_csv(data: List[List[str]]) -> str:
output = io.StringIO()
writer = csv.writer(output)
writer = csv.writer(output, quoting=csv.QUOTE_ALL)
writer.writerows(data)
return output.getvalue()


def csv_string_to_list(csv_string: str) -> List[List[str]]:
output = io.StringIO(csv_string)
output = io.StringIO(csv_string.replace("\x00", ""))
reader = csv.reader(output)
return [row for row in reader]

Expand Down

0 comments on commit ba40a8d

Please sign in to comment.