Cleaning a file for use as a flat file database

Posted on 2005-05-09
Last Modified: 2010-04-16
I have a comma deliminated text file (.csv) I have to use in a program.  The first two rows in the file are blank.  The actual field names (column headers) begin in the 3rd row.  What is the best way to delete those first two rows.  Is there a way to have the person using the program select the row in which the field titles begin and then delete up to that row and reload the file into the database?

Question by:fly412s
    LVL 96

    Expert Comment

    by:Bob Learned
    Would it be possible to use XML?  You can read/write XML from a DataSet with the DataSet.ReadXML and DataSet.WriteXML methods.


    Author Comment

    I might be able to use XML.  I won't know until this Friday, the 13th of May.  I'll be traveling up to my client the end of this week.  I'll check their systems capabilities.


    LVL 3

    Expert Comment

    If you are using a StreamReader, you can simply call ReadLine x number of times without doing anything with the result. x can either be hardcoded or an value that the user supplies. Then do something with the remaining lines.

    Author Comment

    I agree, however, I was looking for a more elegant way such as presenting the file in its entirety via a datagrid or something similar.  Then allowing the user to select the row with the names of the fields (or column headers).  The issue is hardcoding a value and then the structure of the file might change.
    LVL 3

    Accepted Solution

    You could have the number of rows to truncate/delete to be specified by the user. Then its not hardcoded.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now