Skip to content

Spaces in CSV are automatically trimmed #566

@Crazyloon

Description

@Crazyloon

I can't tell if this is intentional, but I am using ExcelDataFactory.CreateCsvReader(fileStream) and when I read a .csv file that contains a space:

Header1,Header2,Header3
value1, ,value3

It is automatically trimmed, so that when I store the value in a string, instead of the value being a literal space, it is an empty string. The workaround is to ensure the value is set as a literal space in the .csv file like so:

Header1,Header2,Header3
value1," ",value3

If you take a look an alternative tool, like the Microsoft.VisualBasic.IO.TextFieldParser, it allows for the TrimWhiteSpace bool to be set to true or false. Setting it to false will cause a value like , , to be read as a literal space.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions