Convert Data table column values into upper case

Dear Forum Members,

I have a data table with 5 to 6 column.
My problem is that i want to convert the values of two columns into upper case values.
For example…
Input:

Col1 Col2 Col3
Ab aa AB
AA ba Ac

Output:

Col1 Col2 Col3
AB AA AB
AA BA Ac

I have large data table so. suggest me the linqquery for the above problem.

Thanks in advance.

Hi @Yankit_singh

You need only one column right?

Regards
Gokul

I need Col1 and Col2’s value in Upper case.

Hi @Yankit_singh ,

Try Below code
df_states.select("", upper(col('Col1')),upper(col('Col2')))

Regards,
Arivu

1 Like

@Yankit_singh

If Yes Try this

  • Read range_1 read the whole datatable save in different Variable Dt1
  • Read range_2 Read only the column you want and pass the range as “A2:B”+(Dt1.rows.Count+1).tostring and save in diff var DT2
  • Output datatable DT2 and create your string variable UpperS
  • Str var = UpperS.ToUpper
  • Generate Datatable CSV Seperators and Comma as column seperators and store in a var and write in the excel in the range of “A2:B”+(Dt1.rows.Count+1).tostring
  • Use Read Range whole value and use it

Regards
Gokul

Hi @Yankit_singh ,

Is this what you are looking for?

image

(From row In Dt_sampleData.AsEnumerable()
Let ls = row.ItemArray.Take(2).ToList()
Let ra = ls.ConvertAll(Function(a) a.ToString.ToUpper).Cast(Of Object).Concat(row.ItemArray.Skip(2)).ToArray()
Select Dt_result.Rows.Add(ra)).CopyToDataTable()

UpperCaseFirstTwoColumns.xaml (7.4 KB)

Kind Regards,
Ashwin A.K

Thanks for the reply.
But what this query will be if the column are at 1st and 3rd position.

Hi @Yankit_singh ,

Please find the updated query below:

image

(From row In Dt_sampleData.AsEnumerable()
Let ra = New Object(){
	Convert.ToString(row(0)).ToUpper,
	row(1),
	Convert.ToString(row(2)).ToUpper,
	row(3)
}
Select Dt_result.Rows.Add(ra)).CopyToDataTable()

Kind Regards,
Ashwin A.K