Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load multiple files from a a concatenated action

Hello friends,

I´m trying to build a code using loop (for each.... next) that loads a several values from a variable which contains the name of the files to load, for instance, separated with comma ','.

eg; I´ve stored in a variable the name of files to load:

alunos 2012-07-30,alunos 2012-06-25, alunos 2012-05-12,alunos 2012-04-03

I wanted to load only these files. As you all may notice, these files are in the format YYYY-MM-DD, and in this example, I´m picking one file of each month.

I´ve managed to load an interval of files using date, but in this case I cannot pick a interval because several files (the other days in the month) doesn´t have to be loaded.

So, is possible to load like the way i was thinking?

Sorry for my english

And thanks in advance.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think you already answered your question by yourself, look at this snippet from the HELP:

for each a in 1,3,7,'xyz'

load * from file$(a).csv;

next

I believe you just need to create your variable that it contains a comma separated list of single quoted literals of your file names, then use this variable in your for each statement:

for each a in $(vFileList)

load * from file$(a).csv;

next

View solution in original post

5 Replies
swuehl
MVP
MVP

I think you already answered your question by yourself, look at this snippet from the HELP:

for each a in 1,3,7,'xyz'

load * from file$(a).csv;

next

I believe you just need to create your variable that it contains a comma separated list of single quoted literals of your file names, then use this variable in your for each statement:

for each a in $(vFileList)

load * from file$(a).csv;

next

Not applicable
Author

I can´t believe tht it´s that simple.

I´ll try and post my result

Thanks swuehl

Not applicable
Author

Qlikview gave me this answer

Não é possível abrir o arquivo'C:\Users\carlos.barreto\Downloads\1-Estacio Producao\QVD_HIST\'ALUNOS 2012-08-02 06_33_00.QVD', 'ALUNOS 2012-07-18 06_08_00.QVD', 'ALUNOS 2012-06-26 03_25_09.QVD', 'ALUNOS 2012-04-30 21_15_00.QVD'' O sistema não pode encontrar o arquivo especificado.

[ALUNOS]:

LOAD NUM_SEQ_TURMA,

     MATRICULA,

     NOME_ALUNO,

     EMAIL_ALUNO,

     CPF_ALUNO,

     COD_INTITUICAO_ALUNO,

     NOM_INSITUICAO_ALUNO,

     P_ACADEMICO_ALUNO,

     COD_CAMPUS_ALUNO,

     CAMPUS_ALUNO,

     TIPO_CURSO_ALUNO,

     TIPO_HABILITACAO_ALUNO,

     COD_CURSO_ALUNO,

     NOM_CURSO_ALUNO,

     P_ACADEMICO_TURMA,

     NOM_DISCIPLINA,

     NOME_DA_DISCIPLINA,

     TURMA_REAL,

     DT_INICIO_DISCIPLINA,

     DT_FIM_DISCIPLINA,

     COD_DISCIPLINA_DISCIPLINA,

     P_ACADEMICO_DISCIPLINA,

     COD_TUTOR,

     NOM_TUTOR,

     EMAIL_TUTOR,

     CPF_TUTOR,

     textbetween(filename(),' ',' ') as data_arquivo

FROM

..\QVD_HIST\'ALUNOS 2012-08-02 06_33_00.QVD', 'ALUNOS 2012-07-18 06_08_00.QVD', 'ALUNOS 2012-06-26 03_25_09.QVD', 'ALUNOS 2012-04-30 21_15_00.QVD'

(qvd)

------------------------------------------------------------

I used this code:

ps:

-------------------------------------------------------

for Each a in vABC_serv2

 

QUALIFY *;

[ALUNOS]:

LOAD NUM_SEQ_TURMA,

     MATRICULA,

     NOME_ALUNO,

     EMAIL_ALUNO,

     CPF_ALUNO,

     COD_INTITUICAO_ALUNO,

     NOM_INSITUICAO_ALUNO,

     P_ACADEMICO_ALUNO,

     COD_CAMPUS_ALUNO,

     CAMPUS_ALUNO,

     TIPO_CURSO_ALUNO,

     TIPO_HABILITACAO_ALUNO,

     COD_CURSO_ALUNO,

     NOM_CURSO_ALUNO,

     P_ACADEMICO_TURMA,

     NOM_DISCIPLINA,

     NOME_DA_DISCIPLINA,

     TURMA_REAL,

     DT_INICIO_DISCIPLINA,

     DT_FIM_DISCIPLINA,

     COD_DISCIPLINA_DISCIPLINA,

     P_ACADEMICO_DISCIPLINA,

     COD_TUTOR,

     NOM_TUTOR,

     EMAIL_TUTOR,

     CPF_TUTOR,

     textbetween(filename(),' ',' ') as data_arquivo

FROM

..\QVD_HIST\$(a)

(qvd);

next a

-----------------------------------------------------------------

There is no problem with the location, because when i load only one it works.

I´m still testing to find a solution. If i find something I´ll post here.

Thanks.

swuehl
MVP
MVP

Try

for Each a in $(vABC_serv2)


Not applicable
Author

Thanks a lot, it worked. As I said here goes the final script.

An usefull thing to remember if anyone try this, is: Usq apostrofe --> '  if you use things other than numbers.

--------------------------------------------------------------------------------

for Each a in $(vABC_serv2)

[ALUNOS]:

LOAD NUM_SEQ_TURMA,

     MATRICULA,

     NOME_ALUNO,

     EMAIL_ALUNO,

     CPF_ALUNO,

     COD_INTITUICAO_ALUNO,

     NOM_INSITUICAO_ALUNO,

     P_ACADEMICO_ALUNO,

     COD_CAMPUS_ALUNO,

     CAMPUS_ALUNO,

     TIPO_CURSO_ALUNO,

     TIPO_HABILITACAO_ALUNO,

     COD_CURSO_ALUNO,

     NOM_CURSO_ALUNO,

     P_ACADEMICO_TURMA,

     NOM_DISCIPLINA,

     NOME_DA_DISCIPLINA,

     TURMA_REAL,

     DT_INICIO_DISCIPLINA,

     DT_FIM_DISCIPLINA,

     COD_DISCIPLINA_DISCIPLINA,

     P_ACADEMICO_DISCIPLINA,

     COD_TUTOR,

     NOM_TUTOR,

     EMAIL_TUTOR,

     CPF_TUTOR,

     textbetween(filename(),' ',' ') as data_arquivo

FROM

..\QVD_HIST\$(a)

(qvd);

next a

END IF;

--------------------------------------------