Code Monkey home page Code Monkey logo

Comments (2)

22222 avatar 22222 commented on July 28, 2024

Yes, the order of lines from the ParseCsvWithHeaderIgnoreErrors function in the README file is guaranteed to be consistent on all iterations.

The IEnumerable interface itself doesn't provide any guarantee on the order of the rows because it's just an interface that could have any implementation. So what matters for the order of the values in the IEnumerable is how it's implemented.

Distilling that README code down to a more basic implementation looks like this:

using (var csvReader = new StringReader(csvInput))
using (var parser = new NotVisualBasic.FileIO.CsvTextFieldParser(csvReader))
{
	while (!parser.EndOfData)
	{
		var fields = parser.ReadFields();
		yield return fields;
	}
}

The key part is the "yield return" statement. That's what the C# compiler uses to generate the returned IEnumerable. For more details, see:

So the values in the returned IEnumerable will always be in the same order because of how the C# "yield return" feature is implemented.

from csvtextfieldparser.

lcocea avatar lcocea commented on July 28, 2024

Thank you! Your Csv parser is excellent, using it in this project: https://github.com/pegasone/cov2con

from csvtextfieldparser.

Related Issues (14)

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.