MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / _split_row

Function _split_row

toon/decoder.py:383–422  ·  view source on GitHub ↗

Split a row by delimiter, respecting quoted strings. Args: row_str: Row string to split delimiter: Delimiter character Returns: List of field values

(row_str: str, delimiter: str)

Source from the content-addressed store, hash-verified

381
382
383def _split_row(row_str: str, delimiter: str) -> List[str]:
384 """
385 Split a row by delimiter, respecting quoted strings.
386
387 Args:
388 row_str: Row string to split
389 delimiter: Delimiter character
390
391 Returns:
392 List of field values
393 """
394 values = []
395 current = []
396 in_quote = False
397 i = 0
398
399 while i < len(row_str):
400 char = row_str[i]
401
402 if char == QUOTE:
403 if in_quote and i + 1 < len(row_str) and row_str[i + 1] == QUOTE:
404 # Escaped quote
405 current.append(QUOTE)
406 i += 2
407 else:
408 in_quote = not in_quote
409 i += 1
410 elif char == delimiter and not in_quote:
411 values.append(''.join(current))
412 current = []
413 i += 1
414 else:
415 current.append(char)
416 i += 1
417
418 # Add last value
419 if current or values:
420 values.append(''.join(current))
421
422 return values
423
424
425def _parse_value(value_str: str, opts: DecoderOptions) -> Any:

Callers 2

_parse_tabular_arrayFunction · 0.85
_parse_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…