Skip to content

Commit

Permalink
fix error loading csv with multiline cells
Browse files Browse the repository at this point in the history
fix limit
  • Loading branch information
bb-mausbrand committed Jan 23, 2025
1 parent 375d513 commit 7792bfd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion viur/scriptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .directory_handler import DirectoryHandler
from .progressbar import ProgressBar

__version__ = '1.0.1'
__version__ = '1.0.1.1'


def version():
Expand Down
4 changes: 2 additions & 2 deletions viur/scriptor/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import chardet
import magic
from openpyxl.reader.excel import ExcelReader
from io import BytesIO
from io import BytesIO, StringIO
import csv
from ._utils import list_table_to_dict_table, normalize_table, list_to_excel, list_to_csv, save_file
from .dialog import Dialog
Expand Down Expand Up @@ -138,7 +138,7 @@ def _csv_data_to_list_table(self, delimiter=None):
params = {'delimiter': delimiter}
else:
params = {}
reader = csv.reader(self.as_text().strip().split('\n'), **params)
reader = csv.reader(StringIO(self.as_text()), **params)
return list(reader)

def as_list_table(self, csv_delimiter=None):
Expand Down
8 changes: 8 additions & 0 deletions viur/scriptor/module_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,21 @@ async def list(self, params: dict = None, group: str = "", skel_type: str = "",
_url.append(group)
_url = join_url(_url)

limit = None
if "limit" in params:
limit = params["limit"]

batch = []
cursor = None
fetched = False

counter = 0
while True:
for i in batch:
yield i
counter += 1
if limit and counter >= limit:
return
if fetched and not cursor:
return
if cursor:
Expand Down

0 comments on commit 7792bfd

Please sign in to comment.