Comments (11)
csv.Configuration.ShouldSkipRecord = record => record.All(string.IsNullOrEmpty);
from csvhelper.
It should already be skipping blank lines. You can also turn on comments CsvReader.Configuration.AllowComments
which will allow for lines that start with '#' to be skippped.
I can add in support for skipping lines that have only commas in them as a config setting. This will be done in the reader though, not the parser. It is a valid row, so the parser should still return an empty one.
from csvhelper.
Hi Josh, sorry for the delay getting back to this one. Yes, a configuration option for this on the reader would be fine.
from csvhelper.
Ok. I will try and get to this soon. I've been working on WinRT support lately.
from csvhelper.
Got this done. 4129ff2
It will be a part of the 1.9 NuGet release.
from csvhelper.
I've just upgrade my solution to use 1.9.0.34342 and I get the following failure in all my tests:
threw exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.All(IEnumerable1 source, Func
2 predicate)
at CsvHelper.CsvReader.IsRecordEmpty(Boolean checkHasBeenRead) in c:\Projects\CsvHelper\src\CsvHelper\CsvReader.cs: line 768
at CsvHelper.CsvReader.Read() in c:\Projects\CsvHelper\src\CsvHelper\CsvReader.cs: line 158
at CsvHelper.CsvReader.d__0`1.MoveNext() in c:\Projects\CsvHelper\src\CsvHelper\CsvReader.cs: line 612
The bug appears to be that the IsRecordEmpty is called after the last record has been read at which point the currentRecord is null.
from csvhelper.
What version of .NET are you using?
from csvhelper.
I’m using 4.0 client profile in the project that references CsvHelper.
From: Josh Close [mailto:[email protected]]
Sent: Tuesday, 23 October 2012 12:58 AM
To: JoshClose/CsvHelper
Cc: Rory Primrose
Subject: Re: [CsvHelper] Add support to automatically skip over blank rows (#53)
What version of .NET are you using?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-9664472.
from csvhelper.
I believe this should be fixed. Version 1.9.2 is on NuGet.
from csvhelper.
For easy reference, this is the setting Josh implemented:
csv.Configuration.SkipEmptyRecords = true;
from csvhelper.
Cannot find SkipEmptyRecords anymore.
Using version 12.x.
How can I skip rows with only separators now?
from csvhelper.
Related Issues (20)
- Just thrown new exception by choice.
- Unexpected `InvalidCastException` in `TypeConverter<>` with nullable structs and value types HOT 2
- List<T>.ToAsyncEnumerable not accessible anymore after upgrade to CSVHelper 31.0.2 (.NET 8) HOT 5
- Set Custom Headers that derives from the property value. HOT 7
- Eliminate the columns if empty HOT 1
- Unregister ClassMap does not clear the previous maps if the same class is used HOT 2
- Getting problems with release build of my app using COM HOT 1
- add my report list columns' name as a header to the csv file when the HasHeaderRecord is set to false
- When Query from db and return IEnumable, will execute 2 times for sql query HOT 3
- Validate Header generate a very large message. HOT 2
- Header does not contain Quote, but some fields in row contain Quote, how should I read this kind of CSV HOT 4
- FastDynamicObject broke serialization HOT 7
- Using a ClassMap with custom type converter results in a "newed" object. HOT 1
- Using Custom TypeConverter causes dangerous/spurious CsvWriter behavior
- csv helper is writing 1 to 12 datetime in different format and 13 to 24 in different datetime format using version 4.0.30319 HOT 1
- FastDynamicObject ignores headers while used together with CsvWriter HOT 1
- Whitespace after delimiter can result in read error HOT 4
- Microsoft.Bcl.AsyncInterfaces dependency issue HOT 4
- [Feature request] Anonymous type and dictionary support HOT 1
- CsvWriter.WriteRecordsAsync does not dispose e.g. EF Core AsyncEnumerators
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 csvhelper.