Solved

How to get Column Names from Data Table

  • 21 June 2023
  • 4 replies
  • 1539 views

Badge +1

I have a bot that accepts a Data Table as an input.  I need to loop through the Data Table and get both the column names as well as the cell values so I can craft a JSON body.  Getting the cell values is straightforward however I cannot figure out how to get the column names.  Any tips?

icon

Best answer by jackson 21 June 2023, 04:56

View original

4 replies

Userlevel 1
Badge +6

are you sure the data table is getting passed in with column names?  this may not be very eligant but if you write the file to a csv or txt file and the open the file without the “contains header checked” then the first record will contain the column names.

 

 

Userlevel 1
Badge +6

I also see that the basic excel has a get column name function so perhaps you write the data table to csv open in with basic excel (which is a light weight excel reader) and use get column name function followed by a loop for the values.

 

Badge +1

Appreciate those suggestions!  Ultimately I suppose I could just add the column names as the first row of data and handle that logic.  Kind of a weird hoop but it works!  Thank you!

Badge

In case you have an option to use csv:

Just imported a csv to a data table and the first row was only headers. Screen shot shows data in first 3 columns at row index 0. 

Hope this helps!

Reply