I have several files (.csv) in a folder.
I need to query a specific file and validate it.
Validation would be looking for data in the file and, once found, validating the line.
Being able to perform the query flow and find the file with the data.
But I don’t know how to validate the specific row within the column.
Could anyone help?
Follow the code below:
urId = result[0].ur_external_reference_id
cy.task('getFiles', 'batch/cerc/22896431000382/unidades_recebiveis/processada')
.then(result => {
const files = result
let continue_loop = true
cy.wrap(continue_loop, { log: false }).as('continue')
for (let i = 0; i < files.length; i++) {
cy.get('@continue', { log: false }).then(continue_loop => {
if (continue_loop) {
cy.readFile(`batch/cerc/22896431000382/unidades_recebiveis/processada/${files[i]}`)
.then(txt => {
if (txt.includes(urId)) {
continue_loop = false
cy.wrap(continue_loop, { log: false }).as('continue')
cy.wrap(txt).as('txt')
}
})
}
})
}
cy.get('@txt').then(txt => {
// cy.log(JSON.stringify(txt))
});
});
Example file
phzSbLtMsETJhBhfuGkd;0010a753-d920-3e20-8346-b79a03ca291e;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
sDgcMYCbcqnrbgrIUkDw;0037ec1f-4ec9-3bd0-9bb1-c999211b1d2e;2024-04-29T20:05:31.618Z;1;"102918;OPERACAO INVALIDA EM UMA UR JA INATIVA OU BAIXADA COM DATA DE LIQUIDACAO ANTERIOR A 90 DIAS"
OdPfhZosiSTqVzxbyBmo;008eafb4-5777-310a-9351-0b67545dd039;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
bcpcEnhnzsXOTVDYuPnc;008fecc8-ab6c-3e33-97d1-e06bce2e0f2d;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
hYPoKOptfRQPqSfgbFBi;0096cac9-9e2b-36fb-ad7f-30661f85cbdd;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
dchoMPWdnhafDvvVuHhX;0097a56d-8cd3-3c9f-abed-56b5a74cc6d2;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
IYPOlsRTRWyFWgBlwDhM;009b0404-2938-38c9-a5c1-3242ead00f91;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
yKnRwTFsPlnKxPzUfIRa;00baee0a-d09c-3be2-8eb8-8c0cb2d9618d;2024-04-29T20:05:31.618Z;1;"102918;OPERACAO INVALIDA EM UMA UR JA INATIVA OU BAIXADA COM DATA DE LIQUIDACAO ANTERIOR A 90 DIAS"
OflUxSWmWdDkomckgLsz;00c12c8a-9856-3d98-a32f-d638cc3d4b3a;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
lCHgHZduncDkrSeurGZY;00c43c4f-d146-3cf0-bab3-067de8a7bd5e;2024-04-29T20:05:31.618Z;1;"102031;ISPB INVALIDO"
I need to look for an id in the file. Example: “hYPoKOptfRQPqSfgbFBi”.
After finding it, I only validate the data from the respective line. More precisely, the penultimate column must be “0”.
Thanks in advance!!