Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Smeenakshi23
Creator II
Creator II

Get List of filed Name in Load script

Hello 

I am using the  below script to fetch all the qvds from the folder.. I need to get list of all fields names..

I don want to use the system filed folder.

could you please suggest 

script:

for each File in filelist(vFolder& '\*.qvd')

load *,

FILENAME() AS TABLENAME

from [$(File)] (qvd)

where RecNo()=1;

next File

 

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

You can read the each QVD meta data for getting list of field name. You can slightly modify your loop like below

TableList:
load * inline [
Junk ];

for each File in filelist(vFolder& '\*.qvd')

concatenate(TableList)
LOAD
    "FieldName",
    filename() as TableName
FROM [$(File)]
(XmlSimple, table is [QvdTableHeader/Fields/QvdFieldHeader]);

NEXT File

drop field Junk;

View solution in original post

8 Replies
Anil_Babu_Samineni

Try this?

'$(File)' as TABLENAME

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Smeenakshi23
Creator II
Creator II
Author

Sorry there is  typo in my subject.. I need field names

jonathandienst
Partner - Champion III
Partner - Champion III

I understand you want a list of field names, but you have nor specified the form that you want them. Do you want to populate a variable, create a new field containing the field names, or some sort of output?

You can use FieldName() in script to get the fields in a table - for example:

For i = 1 To NoOfFields('Table')

    Let vField = FieldName(i, 'Table');
    TRACE Field #$(i): [$(vField)];

Next i

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Table... 

 

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Smeenakshi23
Creator II
Creator II
Author

Sorry about it.. I need new field containing all field names.

jonathandienst
Partner - Champion III
Partner - Champion III

For i = 1 To NoOfFields('Table')

	Let vField = FieldName(i, 'Table');
	TRACE Field #$(i): [$(vField)];
	
	TableFields:
		LOAD $(i) as Index,
		'$(vField)' as FieldName
	AutoGenerate 1;
	
Next i
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
marcus_sommer

One addition to the suggestion from Jonathan - if your files are qvd's you don't need to load (a part) of the file to loop through the loaded fields else you could loop through the meta-data of the qvd by using:

QvdNoOfFields() and QvdFieldName()

instead of

NoOfFields() and FieldName()

- Marcus

Kushal_Chawda

You can read the each QVD meta data for getting list of field name. You can slightly modify your loop like below

TableList:
load * inline [
Junk ];

for each File in filelist(vFolder& '\*.qvd')

concatenate(TableList)
LOAD
    "FieldName",
    filename() as TableName
FROM [$(File)]
(XmlSimple, table is [QvdTableHeader/Fields/QvdFieldHeader]);

NEXT File

drop field Junk;
Smeenakshi23
Creator II
Creator II
Author

thanks a lot