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

Brackets in file name causing load to fail

I am trying to loop through a directory and load all the files within it. Its a simply bit of code, however if one of the filenames contain brackets (), the load will fail. Is there anyway to stop this happening, either by escaping certain characters or changing the load method?

 

 

for each FoundFile in filelist ('lib://Filelocation\*.xlsx')

Input:
LOAD
Field1,
Field2
FROM $(FoundFile)
(ooxml, embedded labels, table is Sheet1);

next FoundFile;

 

 

 

Many thanks!

Rob

Labels (1)
2 Solutions

Accepted Solutions
marcus_sommer

Try it in this way:

for each FoundFile in filelist ('lib://Filelocation\*.xlsx')

Input:
LOAD
Field1,
Field2
FROM [$(FoundFile)]
(ooxml, embedded labels, table is Sheet1);

next FoundFile;

- Marcus

View solution in original post

sunny_talwar

Try by adding single quotes around the variable name after FROM

FOR Each FoundFile in filelist ('P:\Com\Test Loop With Parenthesis\Test\*.xlsx')

	Input:
	LOAD Field1, Field2
	FROM '$(FoundFile)'
	(ooxml, embedded labels, table is Sheet1);

NEXT FoundFile;

View solution in original post

3 Replies
marcus_sommer

Try it in this way:

for each FoundFile in filelist ('lib://Filelocation\*.xlsx')

Input:
LOAD
Field1,
Field2
FROM [$(FoundFile)]
(ooxml, embedded labels, table is Sheet1);

next FoundFile;

- Marcus

sunny_talwar

Try by adding single quotes around the variable name after FROM

FOR Each FoundFile in filelist ('P:\Com\Test Loop With Parenthesis\Test\*.xlsx')

	Input:
	LOAD Field1, Field2
	FROM '$(FoundFile)'
	(ooxml, embedded labels, table is Sheet1);

NEXT FoundFile;
robertmlawton
Contributor II
Contributor II
Author

Thanks guys, both solutions worked perfectly!