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

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
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
 
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...
 
Back
Top