Cleaning a file for use as a flat file database

Posted on 2005-05-09
Medium Priority
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
  • 2
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 13962669
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

ID: 13963334
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.



Expert Comment

ID: 13963342
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

ID: 13963403
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.

Accepted Solution

mpf1748 earned 250 total points
ID: 13963903
You could have the number of rows to truncate/delete to be specified by the user. Then its not hardcoded.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

850 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