Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

csv file load issue identical field names different data

Wondered if you could help me out with this issue I am having with a csv file load. I am loading a csv extract from an  SAP product table that has 2 identical field names but different data in each field. The first field is an  alpha numeric code and the second is a description.

The issue

When I load this file and rename these fields to Product code and Product description, they are both populated with the description data from the second field. If you comment out the second field, it still loads the description from the second field and not the code from the first field. I have never come across this issue and I am assuming that it is skipping the contents of the first field for some reason. Bizarre!

I have tried separating the columns, but it still happens. If you load the file without the embedded column names, it loads as normal.

Attached is an example of what I am loading. Am missing something obvious

Cheers

Brett

5 Replies
swuehl
MVP
MVP

Try

Directory;

LOAD @1  as Material,

          @2  as [Product Hierarchy Code],

          @3  as [Product Hierarchy Description],

          @4  as [SG GRP],

           @5 as Manufacturer

FROM

SalesProducts.csv

(txt, codepage is 1252, no labels, delimiter is ',', msq, header is 1 lines);

Not applicable
Author

Hi,

use below script to get the required:

Directory;

LOAD @1 as Material,

     @2 as [Product Hierarchy Code],

     @3 as [Product Hierarchy Descriptio],

     @4 as [SG GRP],

     @5 as Manufacturer

FROM

SalesProducts.csv

(txt, codepage is 1252, no labels, delimiter is ',', msq, filters(

Remove(Row, Pos(Top, 1))

));

Niranjan M.

Not applicable
Author

Thanks

I have implemented this solution but its annoying when you have a bunch of columns to rename.

Not applicable
Author

I have placed a support call as this may be a bug

Cheers

Brett

rbecher
MVP
MVP

I think this is not a QlikView bug. However there is a programmatically solution for this kind of header issues using a RENAME Fields command with a Mapping table:

Header:

FIRST 1 LOAD @1:n as First_Line

FROM SalesProducts.csv

(fix, codepage is 1252);

Map_Fields:

MAPPING LOAD Field1, if(Field2=Previous(Field2), Field2 & '_2nd', Field2) as Field2;

LOAD '@' & RecNo() as Field1, Field2;

LOAD SubField(First_Line, ',') as Field2

Resident Header;

Drop Table Header;

SalesProducts:

LOAD @1,

     @2,

     @3,

     @4,

     @5

FROM SalesProducts.csv

(txt, codepage is 1252, no labels, delimiter is ',', msq, header is 1 lines);

RENAME Fields using Map_Fields;

- Ralf

Astrato.io Head of R&D