Skip to main content
Solved

How to get Column Names from Data Table


Forum|alt.badge.img+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?

Best answer by jackson

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.

 

 

View original
Did this topic help answer your question?

4 replies

Forum|alt.badge.img+8
  • Navigator | Tier 3
  • 21 replies
  • Answer
  • June 21, 2023

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.

 

 


Forum|alt.badge.img+8
  • Navigator | Tier 3
  • 21 replies
  • June 21, 2023

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.

 


Forum|alt.badge.img+1
  • Author
  • Cadet | Tier 2
  • 1 reply
  • June 21, 2023

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!


Forum|alt.badge.img
  • Cadet | Tier 2
  • 3 replies
  • June 21, 2023

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!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings