Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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
MVP
MVP

Re: Extract Data from TXT file

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

Re: Extract Data from TXT file

Massimo!!!

Thanks a Lot!!!

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

How can i join all the files results???

Regards!!!

MVP
MVP

Re: Extract Data from TXT file

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

Re: Extract Data from TXT file

You are the Best!!!

You save my life!!

Thanks a lot!!!!

Thast Correct!!!!

Community Browser