Comments (2)
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:
- https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/yield
- https://stackoverflow.com/questions/742497/yield-statement-implementation
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.
Thank you! Your Csv parser is excellent, using it in this project: https://github.com/pegasone/cov2con
from csvtextfieldparser.
Related Issues (14)
- add some constructor parameters HOT 3
- Assembly signing HOT 2
- Thanks! HOT 2
- This parser doesn't support multiple delimiters HOT 1
- Suggestion: Include a CsvTextFileFormatter as well? HOT 1
- Can you please add ReadLine() method? HOT 3
- No errorLine is shown when thrown MalformedException HOT 3
- Cannot parse some csv file HOT 3
- Parsing difference between VB parser and this parser HOT 1
- Feature Request: LineNumber property HOT 1
- Issue with line parsing HOT 1
- TrimWhiteSpace default value HOT 3
- Error: is too long, or a component of the specified path is too long. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csvtextfieldparser.