Getting the DataType of a Specific Column in a Data Table

Hello @postwick @supermanPunch @Yoichi, Thank you so much for sharing your feedback.

@Yoichi I certainly didn’t know about the default column type when reading a CSV. I thought Studio would have identified datatype accordingly, I guess I was wrong. Also, I thought the same thing when using an Excel file, but it seems that it never captures the data types no matter what Preserve Format configuration you use.

I did an experiment with all the options available and the only two results I got for the datatypes of the columns were either Object or String. When getting Object the filtering does work.

What I don’t understand about all of this is that days ago I had a similar discussion but working with DateTime values, and the result was that when working with columns that had a DateTime value, depending on the Preserve Format option you used the result of the final datetime format values of the column were different. You can see details here (Read Range stays pending & Date conversión issue - #5 by Luis_Fernando)

So this leaves me with these questions

  • How is it that when reading the Excel file and storing it in the output data table the datetime values are changed from the original format and when asking for the datatype the result is either string or object?

  • Is not possible that when reading an Excel file I can obtain the datatypes corresponding to the content of each column? When I check the Data Table information from the locals panel when debugging it seems to capture the correct data types for the values. Is this not relevant at all when manipulating the data?

These are the results of every configuration of the Preserve Format and the result of the columns DataType and whether the filtering works or not

Read Range Workbook
Preserve Format Configuration = True
Columns DataTypes = System.Objects
Result = Filtering of Doubles doesn’t work

Read Range Workbook
Preserve Format Configuration = False
Columns DataTypes = System.Objects
Result = Filtering of Doubles does work

As you can see for the Read Range Workbook the DataTypes does not change, but the result of the filtering does based on the Preserve Format configuration, That makes me really confused and question everything :face_with_monocle:. Am I asking the wrong question here? , Is the DataType not the issue?

Use Excel File
Preserve Format Configuration = Null
Columns DataTypes = System.String
Result = Filtering of Doubles doesn’t work

Use Excel File
Preserve Format Configuration = Default
Columns DataTypes = System.String
Result = Filtering of Doubles doesn’t work

Use Excel File
Preserve Format Configuration = RawValue
Columns DataTypes = System.Object
Result = Filtering of Doubles does work

Use Excel File
Preserve Format Configuration = DisplayValue
Columns DataTypes = System.String
Result = Filtering of Doubles doesn´t work

PD:

@Yoichi I found your LINQ Query very useful and I might use it for this automation or any other., Thank you very much.


Thank you all, hopefully we can keep discussing the matter, Best Regards.

Luis Fernando Pazos, The Fisrt Venezuelan RPA Developer :stuck_out_tongue_closed_eyes: