Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
oscarvictory
Contributor III
Contributor III

Loading from txt into one row

Hi all, here is a problem I came across when reading from flat file.

The file type is EDIFACT and after applying the delimeter the fnal struture is like that showing the rows needed:

oscarvictory_0-1606043494888.png

and this is my result after the load script:

oscarvictory_1-1606043567530.png

What I would like is all the fields into one row:

oscarvictory_2-1606043637516.png

Here is my script, any help will be appreciate. Many TKS!

LOAD

if (@1 = 'UNH' and mid( @3,1,6) = 'COPARN', @@3) as FileType,
If (@1 = 'RFF' and mid( @2,1,3) = 'ACA', mid( @2,5,25 )) as ValueField,
If (@1 = 'DTM' and mid( @2,1,2) = '76', mid( @2,4,8 )) as Date,
If (@1 = 'DTM' and mid( @2,1,2) = '76', mid( @2,12,4 )) as Time

FROM [lib://COPARNS (qlik_abc)/*.*]
(txt, codepage is 28591, no labels, delimiter is '+', msq)

// I need only the COPARNS FileType
WHERE match(RecNo( ), 2, 5) and Match( mid( @3,1,6), 'COPARN' )
and Match(  @1, 'RFF' , 'DTM')

 

 

1 Solution

Accepted Solutions
QFabian
Specialist III
Specialist III

Hi @oscarvictory , try this please :

Data2:
load * inline [
FileType, ValueField,Date,Time
COPARN,,,
,43678,,
,,20201121,
,,,1630
];

Data3:
Load
*,
rowno() as id
Resident Data2;
drop table Data2;

Data:
Load
FileType
Resident Data3
Where id = 1;

left join
Load
distinct
1 as id,
ValueField
Resident Data3
Where id = 2;
left join
Load
distinct
1 as id,
Date
Resident Data3
Where id = 3;
left join
Load
distinct
1 as id,
Time
Resident Data3
Where id = 4;
drop table Data3;

QFabian

View solution in original post

4 Replies
QFabian
Specialist III
Specialist III

Hi @oscarvictory , try this please :

Data2:
load * inline [
FileType, ValueField,Date,Time
COPARN,,,
,43678,,
,,20201121,
,,,1630
];

Data3:
Load
*,
rowno() as id
Resident Data2;
drop table Data2;

Data:
Load
FileType
Resident Data3
Where id = 1;

left join
Load
distinct
1 as id,
ValueField
Resident Data3
Where id = 2;
left join
Load
distinct
1 as id,
Date
Resident Data3
Where id = 3;
left join
Load
distinct
1 as id,
Time
Resident Data3
Where id = 4;
drop table Data3;

QFabian
oscarvictory
Contributor III
Contributor III
Author

Hi QFabian,

Many thanks for your quick response. It worked perfect!, but sorry for my ignorance: where do I have to insert my 

LOAD...

FROM [lib://COPARNS (qlik_abc)/*.*]
(txt, codepage is 28591, no labels, delimiter is '+', msq)

 

RGDS.

QFabian
Specialist III
Specialist III

Hi, you should replace this :

Data2:
load * inline [
FileType, ValueField,Date,Time
COPARN,,,
,43678,,
,,20201121,
,,,1630
];

QFabian
oscarvictory
Contributor III
Contributor III
Author

Great!!