Coder Social home page Coder Social logo

Comments (9)

JoshClose avatar JoshClose commented on June 9, 2024

Do you have a file that reproduces the issue?

from csvhelper.

ksouthworth avatar ksouthworth commented on June 9, 2024

Yes, how do i upload it?

from csvhelper.

ksouthworth avatar ksouthworth commented on June 9, 2024

Also, I have a workaround that appears to work. I'm reading the input into a string, normalizing the line endings to Windows format CRLF and then converting that back into a stream before passing it in to the CsvReader.

Code snippet i'm using:

            string inputString = reader.ReadToEnd();
            string normalizedLineEndings = Regex.Replace(inputString, @"\r\n|\n|\r", "\r\n");

from csvhelper.

JoshClose avatar JoshClose commented on June 9, 2024

Can you email me the file?

I have a feeling that using a Regex will slow down performance quite a bit.

from csvhelper.

JoshClose avatar JoshClose commented on June 9, 2024

If you change the check in the parser for '\n' to a '\r', your file works correctly. I can add an option for settings the line terminator with a default of '\n', and you could set it to '\r' if the file needs that.

Let me know if that solves the issue for you.

I will look into having it automatically figure it out also, but I haven't given any thought to if that's a good idea yet.

from csvhelper.

JoshClose avatar JoshClose commented on June 9, 2024

I put a new version up that allows you to choose what the line ending is. I tested with your file, and it should work fine if you just change the line ending to \r instead of the default \n.

from csvhelper.

ksouthworth avatar ksouthworth commented on June 9, 2024

Haven't tested yet, but my problem is that I don't know ahead of time which line ending the files will have (the file is uploaded by the user). So I can't hard-code the line terminator...

from csvhelper.

JoshClose avatar JoshClose commented on June 9, 2024

Ok, I will have to give that some thought. I think I should be able to do it fairly easily if I only worry about \r and \n line terminators.

from csvhelper.

JoshClose avatar JoshClose commented on June 9, 2024

RFC 4180 says that the file format has line endings of CRLF, so technically the CSV files you have aren't valid. I updated it so it will use either CRLF, CR, or LF for line endings. I removed the option of specifying the line ending.

from csvhelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.