Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

cocosmina
Contributor II

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
Highlighted
MVP & Luminary
MVP & Luminary

Re: Store fields name in CSV

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

Re: Store fields name in CSV

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

cocosmina
Contributor II

Re: Store fields name in CSV

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

Highlighted
MVP & Luminary
MVP & Luminary

Re: Store fields name in CSV

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