Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Extract Data from TXT file

Hi to all!!!

I need to extract 4 spefic datas from a non parsed txt file.

The example file its attached.

The datas tha i need are:

- Pagador nro.

- Nro. Doc. Pago

- Fecha pago

- Importe

In the example, the result should be:

- Pagador nro. = 9663322

- Nro. Doc. Pago = 116062

- Fecha pago  =  16/07/15

- Importe  = 19.787,24

Please, can some help me????

Regards!!!

4 Replies
maxgro
MVP
MVP

1.png

Directory;

tmp:

LOAD

  *,

  if(wildmatch(@1, '*Pagador nro.*'), subfield(trim(replace(@1, 'Pagador nro.', '')), ' ', 1)) as Pagador,

  if(wildmatch(@1, '*Nro. Doc. Pago*'), Right(@1, len(@1) - index(@1, 'Nro. Doc. Pago') - len('Nro. Doc. Pago'))) as NroDocPago,

  if(wildmatch(@1, '*Fecha pago*'), trim(Right(@1, len(@1) - index(@1, 'Fecha pago') - len('Fecha pago')))) as FechaPago,

  if(wildmatch(@1, '*  Importe  *'), trim(Right(@1, len(@1) - index(@1, 'Importe') - len('Importe')))) as Importe

  ;

LOAD

  @1

FROM

OPAGO_47480_2.TXT

(txt, codepage is 1252, no labels, delimiter is '\t', msq)

Where WildMatch(@1, '*pagador*', '*fecha*', '*importe*')

;

final:

load Pagador Resident tmp where len(trim(Pagador))>0;

join (final) load NroDocPago Resident tmp where len(trim(NroDocPago))>0;

join (final) load FechaPago Resident tmp where len(trim(FechaPago))>0;

join (final) load Importe Resident tmp where len(trim(Importe))>0;

DROP Table tmp;

Not applicable
Author

Massimo!!!

Thanks a Lot!!!

It works for one file. But i have many files.

How can i join all the files results???

Regards!!!

maxgro
MVP
MVP

Directory;

for Each file in FileList('OPAGO_47480_*.TXT')

  tmp:

  LOAD

  *,

  if(wildmatch(@1, '*Pagador nro.*'), subfield(trim(replace(@1, 'Pagador nro.', '')), ' ', 1)) as Pagador,

  if(wildmatch(@1, '*Nro. Doc. Pago*'), Right(@1, len(@1) - index(@1, 'Nro. Doc. Pago') - len('Nro. Doc. Pago'))) as NroDocPago,

  if(wildmatch(@1, '*Fecha pago*'), trim(Right(@1, len(@1) - index(@1, 'Fecha pago') - len('Fecha pago')))) as FechaPago,

  if(wildmatch(@1, '*  Importe  *'), trim(Right(@1, len(@1) - index(@1, 'Importe') - len('Importe')))) as Importe

  ;

  LOAD

  @1

  FROM

  $(file) //OPAGO_47480_2.TXT

  (txt, codepage is 1252, no labels, delimiter is '\t', msq)

  Where WildMatch(@1, '*pagador*', '*fecha*', '*importe*')

  ;

  final:

  load Pagador Resident tmp where len(trim(Pagador))>0;

  join (final) load NroDocPago Resident tmp where len(trim(NroDocPago))>0;

  join (final) load FechaPago Resident tmp where len(trim(FechaPago))>0;

  join (final) load Importe Resident tmp where len(trim(Importe))>0;

  DROP Table tmp;

  final2:

  load '$(file)' as File, * Resident final;

  DROP Table final; 

NEXT;

1.png

Not applicable
Author

You are the Best!!!

You save my life!!

Thanks a lot!!!!

Thast Correct!!!!