sort column as int, not string after populate dataTable from a file

R

Ryan Liu

Hi,

I read a csv file to a datatable. I don't know what are the column types at
this moment, so I treat all columns as string type.

After I read data from file, I use dataTable.Select(condition) to select
some lines.

The problem is with numeric columns, since in datatable, it is string type,
it compares rows as string so make Select() return wrong set of rows.

I was trying to change DataColumn type, but it is an error since there are
already data in the column.

What is the best way to solve this problem? Any input is highly appreciated!

Ryan Liu
 
G

Guest

Ryan,

You could use Convert function within your select - this way you will be
able to compare as a numeric datatype.
Not sure how can you know that a column contains numeric values when using
Select, but cannot use this knowledge when loading the data...
 

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