Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn22-Oct-10 15:25
sitebuilderLuc Pattyn22-Oct-10 15:25 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
PIEBALDconsult22-Oct-10 16:42
mvePIEBALDconsult22-Oct-10 16:42 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn22-Oct-10 16:43
sitebuilderLuc Pattyn22-Oct-10 16:43 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
Brady Kelly22-Oct-10 19:23
Brady Kelly22-Oct-10 19:23 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff22-Oct-10 22:21
mveOriginalGriff22-Oct-10 22:21 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
PIEBALDconsult15-Dec-10 7:40
mvePIEBALDconsult15-Dec-10 7:40 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Brady Kelly15-Dec-10 19:39
Brady Kelly15-Dec-10 19:39 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff22-Oct-10 23:39
mveOriginalGriff22-Oct-10 23:39 
Please ignore my earlier solution - I have been playing with the one Brady supplied, and I am impressed how easily and how well it works:
Add a reference to FileHelper.
Add a class:
using System;
using FileHelpers;

namespace GUITester
    {
    /// <summary>
    /// Dummy class to check FileHelper functionality.
    /// </summary>
    [DelimitedRecord(",")]
    public class Customer
        {
        #region Constants
        #endregion

        #region Fields
        #region Internal
        #endregion

        #region Property bases
        #endregion

        #region FileHelper interaction
        public int Id;
        public string Location;
        [FieldQuoted(), FieldConverter(ConverterKind.Date, "yyyy, MM/dd")]
        public DateTime AccessDate;
        [FieldQuoted(), FieldConverter(ConverterKind.Date, "yyyy, MM/dd")]
        public DateTime CreateDate;
        #endregion
        #endregion

        #region Properties
        #endregion

        #region Regular Expressions
        #endregion

        #region Enums
        #endregion

        #region Constructors
        #endregion

        #region Events
        #region Event Constructors
        #endregion

        #region Event Handlers
        #endregion
        #endregion

        #region Public Methods
        #endregion

        #region Overrides
        #endregion

        #region Private Methods
        #endregion
        }
    }

Add code to your form:
using FileHelpers;
...
            FileHelperEngine engine = new FileHelperEngine(typeof(Customer));
            Customer[] customers = engine.ReadFile(@"F:\Temp\Records.txt") as Customer[];
            foreach (Customer c in customers)
                {
                Console.WriteLine(c.Id + ": ");
                Console.WriteLine("   >" + c.Location);
                Console.WriteLine("   >" + c.AccessDate);
                Console.WriteLine("   >" + c.CreateDate);
                }
And by George it works!
I am very impressed indeed. If you use it, vote the article a five, it deserves it...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn23-Oct-10 2:45
sitebuilderLuc Pattyn23-Oct-10 2:45 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff23-Oct-10 3:43
mveOriginalGriff23-Oct-10 3:43 
QuestionClose Pop Up windows Pin
SatyaKeerthi1522-Oct-10 3:11
SatyaKeerthi1522-Oct-10 3:11 
AnswerRe: Close Pop Up windows Pin
Not Active22-Oct-10 3:22
mentorNot Active22-Oct-10 3:22 
QuestionAnnoying ListBox problem [SOLVED] Pin
Henry Minute22-Oct-10 3:10
Henry Minute22-Oct-10 3:10 
AnswerRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 4:35
sitebuilderLuc Pattyn22-Oct-10 4:35 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 4:42
mveOriginalGriff22-Oct-10 4:42 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:16
sitebuilderLuc Pattyn22-Oct-10 5:16 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 4:46
Henry Minute22-Oct-10 4:46 
AnswerRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:13
sitebuilderLuc Pattyn22-Oct-10 5:13 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 5:14
mveOriginalGriff22-Oct-10 5:14 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:17
sitebuilderLuc Pattyn22-Oct-10 5:17 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 5:24
mveOriginalGriff22-Oct-10 5:24 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:19
sitebuilderLuc Pattyn22-Oct-10 5:19 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 5:30
Henry Minute22-Oct-10 5:30 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:59
sitebuilderLuc Pattyn22-Oct-10 5:59 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 6:06
Henry Minute22-Oct-10 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.