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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
terrusie
Contributor II
Contributor II

Data parsing challenge

Hello.  I'm having trouble Loading data in because of its strange format, and I am not permitted to alter the data file.  I imagine that I will need to use subfield somehow, but I'm at a loss as to how Qlikview can get it into the right form.

Here's the form of the data in the data file:

IdentifierSeries

100

1 - Orange / 4 - Purple / 10 -Yellow
20011 - Green / 60 - Orange
5001 - Purple / 4 - Green  / 10 - Yellow / 30 - Orange

I need to load the data into three related fields as shown below:

IdentifierSeries NumberSeries Type
1001Orange
1004Purple
10010Yellow
20011Green
20060Orange

500

1Purple
5004Green
50010Yellow
50030Orange

Ideally, I would arrange the data file to be more friendly to the load, but I have no control over the file or its format (it is used for other purposes that depend on the format it's in).  Any ideas on how to do this?

1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD Identifier,

Trim(SubField(Series, '-', 1)) as [Series Number],

Trim(Mid(Series, Index(Series, '-', 1) + 1)) as [Series Type];

LOAD Identifier,

SubField(Series, '/') as Series;

LOAD * INLINE [

    Identifier, Series

    100, 1-Orange-ST1 / 4-Purple-ST3 / 10-Yellow-ST6

    200, 11 - Green / 60 - Orange

    500, 1 - Purple / 4 - Green  / 10 - Yellow / 30 - Orange

];

View solution in original post

4 Replies
sunny_talwar

Try this

Table:

LOAD Identifier,

Trim(SubField(Series, '-', 1)) as [Series Number],

Trim(SubField(Series, '-', 2)) as [Series Type];

LOAD Identifier,

SubField(Series, '/') as Series;

LOAD * INLINE [

    Identifier, Series

    100, 1 - Orange / 4 - Purple / 10 -Yellow

    200, 11 - Green / 60 - Orange

    500, 1 - Purple / 4 - Green  / 10 - Yellow / 30 - Orange

];

terrusie
Contributor II
Contributor II
Author

Sunny,

Thanks.  I have one other problem.  Evidently the data have 2 "-" and only the first one matters:

Example:

100, 1-Orange-ST1 / 4-Purple-ST3 / 10-Yellow-ST6

Where the "Series Type" should be:

Orange-ST1

Purple-ST3

Yellow-ST6

Is there a way to say:

Subfield(Series,'-',Everything after the first)?

sunny_talwar

Try this

Table:

LOAD Identifier,

Trim(SubField(Series, '-', 1)) as [Series Number],

Trim(Mid(Series, Index(Series, '-', 1) + 1)) as [Series Type];

LOAD Identifier,

SubField(Series, '/') as Series;

LOAD * INLINE [

    Identifier, Series

    100, 1-Orange-ST1 / 4-Purple-ST3 / 10-Yellow-ST6

    200, 11 - Green / 60 - Orange

    500, 1 - Purple / 4 - Green  / 10 - Yellow / 30 - Orange

];

terrusie
Contributor II
Contributor II
Author

Sunny,

Thanks a bunch! 

I had no idea that "Mid" existed.  I have to remember that one.  I only knew about Subfield, Left, and Right (which all had their quirks when it came to the redundant hyphen).