Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
arngue
Contributor III
Contributor III

How to load filename as a column inside for loop in load script


Let vFile = '';

for each FoundFile in filelist( '.\txt\*.txt')

Let vFile = SubField(Text($(FoundFile)),'\txt\',2);

Table1:
Load
$(vFile)

 

Why this variable does not work?

image.png

 

for each FoundFile in filelist( '.\txt\*.txt')

Table1:
Load
SubField(‘$(FoundFile)’,'\txt\',2) as file,

image (1).png

I can't get this to work. I'm lost.

Labels (4)
1 Solution

Accepted Solutions
sunny_talwar

Try this

Table1:
LOAD SubField('$(FoundFile)','\txt\',2) as file,

Your single quotes look like another type of quotes

View solution in original post

2 Replies
sunny_talwar

Try this

Table1:
LOAD SubField('$(FoundFile)','\txt\',2) as file,

Your single quotes look like another type of quotes

Anil_Babu_Samineni

How about simply doing?

Load FileName() as FileName From Table;

If you need your way, try this?

Let vFile = '';

for each FoundFile in filelist( '.\txt\*.txt')

LET vCount = NoOfRows('$(FoundFile)');

Table1:
Load
SubField($(FoundFile),'\txt\',2) as File

Autogenerate $(vCount);

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