Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Pretty much, as it says in the topic, how would I use the first row as the fields' names for that table?
Here's an example of what I mean:
LOAD * INLINE [
@1, @2, @3, @4
Product, Jan, Feb, Mar
p1, 10, 20, 30
p2, 11, 21, 31
p3, 12, 22, 32
];
What I need to get out of this is:
Product | Jan | Feb | Mar
-----------------------------
p1 | 10 | 20 | 30
p2 | 11 | 21 | 31
p3 | 12 | 22 | 32
One of the ways I can think of is to STORE the table as a CVS and then re-load it as a new table with embedded headers, but that's not very elegant as this portion is in a nested loop.
Thanks,
Siarhei K.
Use the peek function to get the values and rename statement to change the field names. Use a for loop to cycle through each field with NoOfFields function value to determine the number of iterations. I do stuff like this sometimes for crazy purposes.
Then you'll (obviously) want to remove the 1st row from the table. Last I checked QV doesn't have a glamorous way to do this (like an SQL DELETE statement.) You can accomplish this a few different ways; post back if you need help.
If I read this correctly all you need to do is just delete the @1, @2...row in your inline statement. When using inline the first row is used as field names.
Yes, i get that, but this was just an example.
Imagine that I already have a table (loaded from somewhere and processed a zillion times) where the field names are useless to me, since the first row contains the information that I would like to use as the new fields' names for that same table.
Use the peek function to get the values and rename statement to change the field names. Use a for loop to cycle through each field with NoOfFields function value to determine the number of iterations. I do stuff like this sometimes for crazy purposes.
Then you'll (obviously) want to remove the 1st row from the table. Last I checked QV doesn't have a glamorous way to do this (like an SQL DELETE statement.) You can accomplish this a few different ways; post back if you need help.
Wow, you're on a roll!
Thanks again.