Data View question

Hi,
I am trying to use dataview(myDataTable).toTable(false, selectColNames}

where selectColNames is a string array, which has column names with special characters like %, ’ in it. For example “% Score”, “Resource’s Phone”. I am getting other columns if I do not include columns with special characters. Escaping the special characters is not helping like “% Score”. Can you please help?

Thanks,

can you try:

YourDataTableVar.DefaultView.toTable(False, arrColNamesToSelect)

arrColNamesToSelect = String Array with Column Names which are to select

grafik

Thank you,
I get System.ArgumentException.
At the first special character in the column name, in the above example ‘%Score’ does not belong to underlying Table.

If I remove ‘%score’ then I get this exception “Resource’s Phone” does not belong to underlying Table.

Hi,

If possible, can you share your datatable as a file using WriteCSV etc? It’s no problem if dummy data.

Regards,

Hi, Is there a way to rename columns using DataView.ToTable? Thanks much!

Hi @A_Learner ,

You can’t rename columns using the DataView Method.
It is only used to retrieve unique/duplicate values from select columns .

Regarding your issue, we would appreciate it if you could share a sample dataset with us as that would put us in a much better position to assist you.

Kind Regards,
Ashwin A.K

Hi

We need to consider three things here

  1. First if you want to change the columnname then we can use a assign activity like this

datatable.Columns(0).ColumnName = “any new name”

This can’t be done with DefaultView method

  1. Then if you would like to get only certain number of columns from a datarable with multiple columns then we can use a DefaultView method like this

dt = dt.DefaultView.ToTable(False, columnarray)

  1. And finally if you are getting this error

Make sure you don’t have same column names in that DATATABLE itself or make sure the column name is same as in DATATABLE

Finally if you want to delete just one or two columns from the main DATATABLE and get the remaining
Then you can directly use REMOVE DATACOLUMN activity

Cheers @A_Learner

1 Like

Excellent! Thanks for all the help.

1 Like

Glad it got resolved @A_Learner

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.