1

My CSV File Is as below ,

Name,Place,                   <<--- Headers
Panindra,India,
Kumar,India,

As one can see the csv file contains extra "Comma" at end of each line instead of blank . and Row Breaker / Line Seperator is missing and hence Its showing error in parsing csv file in "FILE HELPERS" . getting error as "extra comma is found at the end of filed ['Place'] "

how to solve this issue ??

my Delimiter CLass goes like this

using FileHelpers;
namespace CsvReader.Model
{ 

        [DelimitedRecord(",")]

        public class CSVModel
        {

        [FieldTrim(TrimMode.Both)]
        public string Name;

        [FieldTrim(TrimMode.Both)]
        public string Place;

}}

    ...

and Parsing Code is like this ...

...

 engine = new FileHelperAsyncEngine<CSVModel>();
                this.engine.Options.IgnoreFirstLines = 1;

engine.BeginReadFile(fullpath);

...
panindra
  • 646
  • 2
  • 11
  • 33
  • please update question with code. – Rakin Oct 22 '15 at 05:54
  • What have you tried so far? How are you attempting to manage this currently? – Ben Oct 22 '15 at 05:55
  • @Ben I tried using FILEHELPER , but failing solve this issue , one thing I can do is read csv file escape "," at every 2 fields using REGEX ,but I want something simple .. – panindra Oct 22 '15 at 06:01

1 Answers1

1

you could write something to preprocess the files like

string[] readText = File.ReadAllLines(path);

for (int i=0;i<readText.length;i++)
{
    readText[i]=readText[i].Trim([',']);
}

File.WriteAllLines(path, readText);
AwokeKnowing
  • 7,728
  • 9
  • 36
  • 47