Merge pull request #659 from danielaskdd/cvs_robustness
Enhance robustness of CVS processing ,Fix potential CSV parsing issues
This commit is contained in:
@@ -918,7 +918,7 @@ def create_app(args):
|
|||||||
case ".pptx":
|
case ".pptx":
|
||||||
if not pm.is_installed("pptx"):
|
if not pm.is_installed("pptx"):
|
||||||
pm.install("pptx")
|
pm.install("pptx")
|
||||||
from pptx import Presentation
|
from pptx import Presentation # type: ignore
|
||||||
|
|
||||||
# PowerPoint handling
|
# PowerPoint handling
|
||||||
prs = Presentation(file_path)
|
prs = Presentation(file_path)
|
||||||
@@ -1216,7 +1216,7 @@ def create_app(args):
|
|||||||
case ".pptx":
|
case ".pptx":
|
||||||
if not pm.is_installed("pptx"):
|
if not pm.is_installed("pptx"):
|
||||||
pm.install("pptx")
|
pm.install("pptx")
|
||||||
from pptx import Presentation
|
from pptx import Presentation # type: ignore
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
# Read PPTX from memory
|
# Read PPTX from memory
|
||||||
@@ -1320,7 +1320,7 @@ def create_app(args):
|
|||||||
case ".pptx":
|
case ".pptx":
|
||||||
if not pm.is_installed("pptx"):
|
if not pm.is_installed("pptx"):
|
||||||
pm.install("pptx")
|
pm.install("pptx")
|
||||||
from pptx import Presentation
|
from pptx import Presentation # type: ignore
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
pptx_content = await file.read()
|
pptx_content = await file.read()
|
||||||
|
@@ -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:
|
def list_of_list_to_csv(data: List[List[str]]) -> str:
|
||||||
output = io.StringIO()
|
output = io.StringIO()
|
||||||
writer = csv.writer(output)
|
writer = csv.writer(output, quoting=csv.QUOTE_ALL)
|
||||||
writer.writerows(data)
|
writer.writerows(data)
|
||||||
return output.getvalue()
|
return output.getvalue()
|
||||||
|
|
||||||
|
|
||||||
def csv_string_to_list(csv_string: str) -> List[List[str]]:
|
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)
|
reader = csv.reader(output)
|
||||||
return [row for row in reader]
|
return [row for row in reader]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user