Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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;
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
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;
Thanks guys, both solutions worked perfectly!