PDA

View Full Version : Assigning table fields to variables?


StealthFD
10-23-2008, 07:31 PM
Hey gang!

Looking for another suggestion... using the DelimitedStringToTable function, what is the best way to take the first row (or header) of a column and assign the content as a variable name?

Here is what I mean:

I need to process tables that always contain the same header fields (ie item1,item2,item3,etc.) but they are not always in the same order or position within the table (ie item2,item1,item3).

Table #1:
item1,item2,item3,item4
bread,milk,eggs,cheese
red,green,blue,yellow

Table #2:
item2,item1,item4,item3
milk,bread,cheese,eggs
green,red,yellow,blue

Both would generate the following:
item1 = bread
item2 = milk
item3 = eggs
item4 = cheese

item1 = red
item2 = green
item3 = blue
item4 = yellow

What is the best way to read that first row of a table and assign the contents to a variable that I can use through the rest of a for-in-do loop?

I hope that makes sense.

Thanks gang!

StealthFD
10-25-2008, 08:51 AM
Was wondering why no one had replied with suggestions and then I re-read my post and I see that my thoughts ran together and kinda mucked thins up...

I need help with tables... Not the DelimitedStringToTable function. I used that to populate the tables. Sorry for the confusion.


Anyway, what I really need is a way to take the header/first row of a table and assign the contents within each item as the variable name.

I need to process tables that always contain the same header fields (ie item1,item2,item3,etc.) but they are not always in the same order or position within the table (ie item2,item1,item3).

Again, sorry about the confusion!

You guys have always been a great help!