Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
Try this?
'$(File)' as TABLENAME
Sorry there is typo in my subject.. I need field names
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
Sorry about it.. I need new field containing all field names.
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
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
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;
thanks a lot