CSV Import : Don't re-invent anything, let alone the wheel

May 15, 2008 14:33 by tim

I've worked with data for the whole of my programming life.  If it's not dbf, mdb, ldf its those annoying Excel spreadsheets people love to send you and just "import" with all the dodgy quotes and pipes etc

I was used to opening the file low-level and reading the file line-by-line, splitting up the fields as we go and inserting the data into the database.  However, people love to put quotes, commas and any combination of quote-comma-quote actually in to the text.  Fine if you're a human, as it makes the reading of the text much easier and feature-filled ; Nightmare if you're a computer as those just look like new fields leaving you with more or less fields than the last record

Those clever guys at Microsoft have done it again with OleDb.  Ever wondered how Excel knows how to delimt the fields properly, given a really poor system of data entry?  I have wondered this for years, putting it down to sheer magic, and the magic really works!!

http://ronaldlemmen.blogspot.com/2008/03/import-csv-file-to-datatable.html has detailed instructions on how to get a CSV file and translate that directly into a DataTable.  DataTables are one of the most logical structures i've used and that format suits me fine

Shazzam!!


Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: Technical
Actions: E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

Related posts

Comments

January 19. 2009 06:41

That’s great that you are teching technology to kids! I just found your blog and it’s really good! I’m going to read more posts!

Philippine data entry

April 30. 2009 06:55

Wow, I never knew that Don't re-invent anything, let alone the wheel. That's pretty interesting...

Anna Scott

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

July 31. 2010 20:15

Calendar

July 2010
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567