Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I did that code :
LET vParentFolderPath = 'lib://04_D/Production/';
// Récupérer la liste des dossiers dans le chemin parent
FOR Each vFolder in DirList('$(vParentFolderPath)*')
Trace 'La première trace est ' $(vFolder);
// LET vFolderPath = '$(vParentFolderPath)$(vFolder)/';
// Trace $(vFolderPath);
// Liste tous les fichiers Excel dans le dossier
FOR Each vFile in FileList('$(vFolder)/*.xlsx')
Trace 'La deuxième trace est ' $(vFile);
// Chargez le contenu du fichier Excel dans une table temporaire
TempTable:
LOAD *
FROM [$(vFile)]
(ooxml, embedded labels, table is [RENDU]);
NEXT
NEXT
It works fine but the problem is that sometimes, I have excel file who has no sheet " RENDU"
So I try to find a solution to skip these file if they don't have the sheet "RENDU"
Somemone has an idea about how I can skip a file excel if he has not the sheet "RENDU" ?
Thanks !
Hi
One Option will be move this data to ODBC so you can control more on the data.
If this is not the case Set errormode = 0 s o he will ignore the error and continue the execution
you can add only in this piece of code the error mode and turn on again like
LET vParentFolderPath = 'lib://04_D/Production/';
// Récupérer la liste des dossiers dans le chemin parent
FOR Each vFolder in DirList('$(vParentFolderPath)*')
Trace 'La première trace est ' $(vFolder);
// LET vFolderPath = '$(vParentFolderPath)$(vFolder)/';
// Trace $(vFolderPath);
//Disable error mode to avoid stop execution because of excel with no RENDU sheet
SET ErrorMode =0 ;
// Liste tous les fichiers Excel dans le dossier
FOR Each vFile in FileList('$(vFolder)/*.xlsx')
Trace 'La deuxième trace est ' $(vFile);
// Chargez le contenu du fichier Excel dans une table temporaire
TempTable:
LOAD *
FROM [$(vFile)]
(ooxml, embedded labels, table is [RENDU]);
NEXT
NEXT
//Enable again the errormode
ErrorMode =1;
Thanks it works,
I 'm trying to add a new variable at my code for additionnal folder.
to explain :
my folder "Production" contains a lot of folder and these lot of folder contains xlsx that I got with that code.
But sometimes I have this :
my folder "Production" contains a lot of folder and these lot of folder contains a lot of folders too who contains xlsx.
Thanks
It's ok, I found how I can do it ,
but can I have a solution to don't see always "error" when I load my script ?
i don't think you will have an solution for that only if crate a name conversion for you excel files and use as base like
Sales_2021.xls
then in your code you search for Sales*.xls
Ok, I got 7 tempory tables.
Can I modify code to have just 1 table with only field I need ?
thanks
What do you mean?
could show the data model ?