Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
m_perreault
Creator III
Creator III

Export List of Fields from Script

Hi All,

I was wondering if there is a way to export the list of fields from a Table in the script.  I know I could go use a Table Object with dimension $Field and export it, but I was wondering if there is a way to do this directly from the load script?

Thanks,
Mark

1 Solution

Accepted Solutions
m_perreault
Creator III
Creator III
Author

The script found here creates the table I am looking for which I can then store.  Fast way to get all table and field names from an app

//Iterate through the loaded tables

For t = 0 to NoOfTables() - 1

//Iterate through the fields of table

  For f = 1 to NoOfFields(TableName($(t)))

   Tables:

   Load

    TableName($(t)) as Table,

    TableNumber(TableName($(t))) as TableNo,

    NoOfRows(TableName($(t))) as TableRows,

    FieldName($(f),TableName($(t))) as Field,

    FieldNumber(FieldName($(f),TableName($(t))),TableName($(t))) as FieldNo

    Autogenerate 1;

  Next f

Next t;

View solution in original post

3 Replies
m_perreault
Creator III
Creator III
Author

Sure this will store all of the fields and their values into a QVD,CSV,TXT file but I am wondering if anyone knows a way to export just the list of fields from a table.  I am currently using the below script to store a list of all the field names as a variable but am getting stuck on how to get them into a table to export.

Let i = 0;

For i = 0 to NoOfFields('Test')

Let vField$(i)= FieldName(i,'Test');

Next i;

m_perreault
Creator III
Creator III
Author

The script found here creates the table I am looking for which I can then store.  Fast way to get all table and field names from an app

//Iterate through the loaded tables

For t = 0 to NoOfTables() - 1

//Iterate through the fields of table

  For f = 1 to NoOfFields(TableName($(t)))

   Tables:

   Load

    TableName($(t)) as Table,

    TableNumber(TableName($(t))) as TableNo,

    NoOfRows(TableName($(t))) as TableRows,

    FieldName($(f),TableName($(t))) as Field,

    FieldNumber(FieldName($(f),TableName($(t))),TableName($(t))) as FieldNo

    Autogenerate 1;

  Next f

Next t;