Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Store fields name in CSV

Hi all,

I need to make an maintenance of fields name. I intend to load all the fields from script into a csv file and i don't know how.

Thank you,

Cosmina

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This script will export a table of TableNames & FieldNames.

FOR tableIdx = NoOfTables()-1 to 0 step -1

  LET vTable = TableName($(tableIdx));

  FOR fieldIdx = 1 to NoOfFields('$(vTable)')

  FieldList:

  LOAD

  '[$(vTable)]' as TableName,

  FieldName($(fieldIdx),'$(vTable)') as FieldName

  AutoGenerate 1;

  NEXT fieldIdx

NEXT tableIdx

STORE FieldList INTO FieldList.csv (txt);

Example attached.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

View solution in original post

3 Replies
its_anandrjs

You can do some way with create the CSV file for your Data model and then work on the field which you want to keep or else you want to delete.

Ex:-

Let vFolder = 'C:\Users\CSV\';

for vCount = 0 to NoOfTables()-1

Let vTableName = TableName($(vCount));

STORE $(vTableName) into $(vFolder)$(vTableName).csv (txt);

next vCount

Regards

Anand

Anonymous
Not applicable
Author

Hi, Thank you for the answer.

I need to export only the header in a single column, not the values and not on separate tables with their values. Meaning, all the fields name from all tables in a single column. And eventually a header on the second column, called New_Field. To understand exactly the process, i am going to send the file to my client, he is going to insert in the second column the new namind and I am going to use Rename Fields using FieldMap;

So, i need a way to prepare the file like as mapping table.

BR

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This script will export a table of TableNames & FieldNames.

FOR tableIdx = NoOfTables()-1 to 0 step -1

  LET vTable = TableName($(tableIdx));

  FOR fieldIdx = 1 to NoOfFields('$(vTable)')

  FieldList:

  LOAD

  '[$(vTable)]' as TableName,

  FieldName($(fieldIdx),'$(vTable)') as FieldName

  AutoGenerate 1;

  NEXT fieldIdx

NEXT tableIdx

STORE FieldList INTO FieldList.csv (txt);

Example attached.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com