Best Way to Read .csv File?

T

TC

Hey All,

I have to read .csv files and display them in a DataGridView.

Currently, I'm dumping the data into a DataTable but it's causing problems
because the engine is automatically converting / deleting material.

I cannot use a .ini file because the .csv files could be called anything and
come from any folder (i.e. it's a 'FileOpen' dialog necessity).

What is the best / quickest way to read .csv files such that the data is not
changed or is understood as strings?

Thanks,

TC
 
T

TC

Hey All,

It appears that one has to read the file using StreamReader, parse the lines
using the appropriate delimeter and then pump in the columns and rows.

The above worked for me.
 
C

Cor Ligthert [MVP]

Not the general best way.

As your CSV file is showable in Excel the you would be able to make dataset
from it (there is a property to distinct numbers from text).

Just for others thinking that what you have choosen is in general the best
way.
(Probably I had done it in your situation the same as you)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top