Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load from multiple text files (dynamic)

From my payroll system, every two weeks a text file is created, which I need to load into qlikview

The text files are all stored in the same hard drive folder (C:\textfiles\) and are named

Payroll_week13-14.txt
Payroll_week15-16.txt

The format of the files are completely the same, and they all need to be concatenated into the same Qlikview table.

How do I create a load statement that dynamically loads ALL text files, no matter if there are 3 or 300 in the folder?
I also need a datafield in the qlikview table that contains the source file name.

Please help. [:D]

regards, Jesper

1 Solution

Accepted Solutions
sparur
Specialist II
Specialist II

Hello, Jesper.

PayrollTable:

LOAD

*,

mid(filename( ), 13, 5) AS WeekNumberData

FROM Payroll_week*.txt (....)

View solution in original post

4 Replies
sparur
Specialist II
Specialist II

Hello, Jesper.

PayrollTable:

LOAD

*,

mid(filename( ), 13, 5) AS WeekNumberData

FROM Payroll_week*.txt (....)

Not applicable
Author

Hi Jesper,

somthing like this should do the trick:

Directory C:\MyData\TXT;

For each txtFile in filelist ('*.txt')

MyTable:
LOAD

Field1,

Field2,
'$(txtFile)' as Name,
FileName('$(txtFile)') as FileName,
FileSize('$(txtFile)') as Size,
FileTime( '$(txtFile)') as FileTime
From '$(txtFile)' ;

NEXT txtFile;

Good luck!

Rainer

Not applicable
Author

Thx guys, i'll give it a go!

jesper

Not applicable
Author

Hi there..

i have a problem with the FROM syntax.

I can doFROM Payroll_*.txt if my filename is Payroll_xyz.txt

it wont work if the filename is Payroll_xyz_2011-08-05.txt.

is this normal? or something is wrong?

LOAD

*,

mid(filename( ), 13, 5) AS WeekNumberData

FROM Payroll_week*.txt (....)