Coder Social home page Coder Social logo

Comments (11)

AltruCoder avatar AltruCoder commented on June 18, 2024 3

@shwedberlin

csv.Configuration.ShouldSkipRecord = record => record.All(string.IsNullOrEmpty);

from csvhelper.

JoshClose avatar JoshClose commented on June 18, 2024

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.

roryprimrose avatar roryprimrose commented on June 18, 2024

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.

JoshClose avatar JoshClose commented on June 18, 2024

Ok. I will try and get to this soon. I've been working on WinRT support lately.

from csvhelper.

JoshClose avatar JoshClose commented on June 18, 2024

Got this done. 4129ff2

It will be a part of the 1.9 NuGet release.

from csvhelper.

roryprimrose avatar roryprimrose commented on June 18, 2024

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, Func2 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.

JoshClose avatar JoshClose commented on June 18, 2024

What version of .NET are you using?

from csvhelper.

roryprimrose avatar roryprimrose commented on June 18, 2024

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.

JoshClose avatar JoshClose commented on June 18, 2024

I believe this should be fixed. Version 1.9.2 is on NuGet.

from csvhelper.

arjendemooij avatar arjendemooij commented on June 18, 2024

For easy reference, this is the setting Josh implemented:

csv.Configuration.SkipEmptyRecords = true;

from csvhelper.

shwedberlin avatar shwedberlin commented on June 18, 2024

Cannot find SkipEmptyRecords anymore.
Using version 12.x.
How can I skip rows with only separators now?

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.