Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8251175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:08:56+00:00 2026-06-08T00:08:56+00:00

Am using the excellent FileHelpers library to parse a number of different files. One

  • 0

Am using the excellent FileHelpers library to parse a number of different files. One of these files has (some) lines that look like this

id|name|comments|date
01|edov|bla bla bla bla|2012-01-01
02|john|bla bla bla bla|2012-01-02
03|Pete|bla bla <NEWLINE>
bla bla|2012-03-01
04|Mary|bla bla bla bla|2012-01-01

Note that line with id 3 has a newline in the text. Also note the comments are not surrounded by quotes so [FieldQuoted('"', MultilineMode.AllowForRead)] isn’t going to save me.

Filehelpers throws an exception on line 4:

Delimiter ‘|’ not found after field ‘comments’ (the record has less
fields, the delimiter is wrong or the next field must be marked as
optional).

Is there anyway I can parse this file with FileHelpers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:08:57+00:00Added an answer on June 8, 2026 at 12:08 am

    You have to correct the input by adding quotes to the third field before passing it to the FileHelpers engine. It’s easy to do with LINQ as demonstrated in the following program.

    [DelimitedRecord("|")]
    [IgnoreFirst(1)]
    public class ImportRecord
    {
        public string Id;
        public string Name;
        [FieldQuoted(QuoteMode.AlwaysQuoted, MultilineMode.AllowForRead)]
        public string Comments;
        public string Date;
    }
    
    class Program
    {
        static void Main(string[] args)
        {
            var engine = new FileHelperEngine<ImportRecord>();
    
            string input = "id|name|comments|date" + Environment.NewLine +
                                  "01|edov|bla bla bla bla|2012-01-01" + Environment.NewLine +
                                  "02|john|bla bla bla bla|2012-01-02" + Environment.NewLine +
                                  "03|Pete|bla bla" + Environment.NewLine +
                                  "bla bla|2012-03-01" + Environment.NewLine +
                                  "04|Mary|bla bla bla bla|2012-01-01";
    
            // Modify import to add quotes to multiline fields
            var inputSplitAtSeparator = input.Split('|');
            // Add quotes around the field after every third '|'
            var inputWithQuotesAroundCommentsField = inputSplitAtSeparator.Select((x, i) => (i % 3 == 2) ? "\"" + x + "\"" : x);
            var inputJoinedBackTogether = String.Join("|", inputWithQuotesAroundCommentsField);
    
            ImportRecord[] validRecords = engine.ReadString(inputJoinedBackTogether);
    
            // Check the third record
            Assert.AreEqual("03", validRecords[2].Id);
            Assert.AreEqual("Pete", validRecords[2].Name);
            Assert.AreEqual("bla bla" + Environment.NewLine + "bla bla", validRecords[2].Comments);
            Assert.AreEqual("2012-03-01", validRecords[2].Date);
    
            Console.WriteLine("All assertions passed");
            Console.ReadKey();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the excellent DuplexHttpBinding . I now want to extend it so that
I wonder whether someone may be able to help me please. Using some excellent
I want to produce a simple, static HTML file, that has one or more
I'm using the excellent OpenIso8583Net to send/receive ISO messages. However, since every organization has
I'm using the excellent jEditable plugin for some in-place editing on my page. There
We are using this excellent plugin for some small sparkline charts. Issue I have
I am using the excellent jQuery MultiSelect plugin. The problem I have is that
I am using some excellent code for a photo slide show from http://www.queness.com/post/1450/jquery-photo-slide-show-with-slick-caption-tutorial-revisited .
I'm doing some simple regexp work in Haskell using this excellent tutorial as a
I'm using the excellent (but large) DateJS library to handle dates and times in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.