Empty strings in a CSV file, such as the middle field in Greg,,The world's Greggest!, causes an exception to be thrown when read.
Example:
from dataclasses import dataclass
from dataclass_csv import DataclassReader, DataclassWriter
from io import StringIO
@dataclass
class Person:
firstname: str
lastname: str
motto: str
csv_data = """firstname,lastname,motto
Greg,,The world's Greggest!
"""
print(list(DataclassReader(StringIO(csv_data), Person)))
Result:
dataclass_csv.exceptions.CsvValueError: The field `lastname` is required. [CSV Line number: 2]
Using dataclass-csv 1.4.0.
Empty strings in a CSV file, such as the middle field in
Greg,,The world's Greggest!, causes an exception to be thrown when read.Example:
Result:
Using dataclass-csv 1.4.0.