Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

harjit_nar
New Contributor

Only load csv files with specific field names

I have a number of .csv files which follow the same naming convention, but have different fields.

The format/fields I require are:

- SERIAL NUMBER

- VERSION

- DATE

- RADIO ID

Example of other files with same naming convention, but different fields:

- SERIAL NUMBER

- COST

- CLASS

- OTHER ID

Is there a way to load only those files with the required fields?

3 Replies
mwoolf
Honored Contributor II

Re: Only load csv files with specific field names

One possibility would be to set errormode = 0 before the load. The files without the correct fields would cause errors, but would be ignored.

antoniotiman
Honored Contributor III

Re: Only load csv files with specific field names

May be like this

Table:

LOAD * From YOURTABLE .....;

LET A = FieldNumber('SERIAL NUMBER','Table')+FieldNumber('COST','Table')+FieldNumber('CLASS','Table')+FieldNumber('OTHER ID','Table');

If A <> 10 then

Drop Table Table;

Exit Script;

Endif;

..............

jftalmeida
New Contributor III

Re: Only load csv files with specific field names

When adding a spreadsheet, use the Labels option equal to None, position it on the line where it starts:

For example:

TableSpreadsheet:

LOAD A as [Serial Number],

    B as [Cost],

    C as [Class],

    D as [Other ID]

FROM

<Path of your Worksheet>

(ooxml, no labels, header is <Place on which line begins> lines, table is <Your Sheet>);

If you rename the labels you will have no problem loading, understand?

Community Browser