Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using a variable in the From statement in the load

Hi,

I'm loading a csv file and part of the name of the file depends on a variable, its looks as it doesn't recognize the variable, I have tried the following and doesn't work, (the variable is vYearMonth)

1.

FROM

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

2.

FROM

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Is there something that I'm missing?

Thanks & regards.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

This works for me

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep='.';

SET MoneyDecimalSep=',';

SET MoneyFormat='€ #.##0,00;-€ #.##0,00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='gen;feb;mar;apr;mag;giu;lug;ago;set;ott;nov;dic';

SET DayNames='lun;mar;mer;gio;ven;sab;dom';

Directory;

SET vYearMonth=201302;

LOAD @1

FROM

[aaa_$(vYearMonth)_bbb.csv]

(txt, unicode, no labels, delimiter is '\t', msq);

SET vYearMonth=201303;

LOAD [03/01/2014 13:39:22:      Execution started.]

FROM

(txt, unicode, embedded labels, delimiter is '\t', msq);

View solution in original post

5 Replies
maxgro
MVP
MVP

This works for me

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep='.';

SET MoneyDecimalSep=',';

SET MoneyFormat='€ #.##0,00;-€ #.##0,00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='gen;feb;mar;apr;mag;giu;lug;ago;set;ott;nov;dic';

SET DayNames='lun;mar;mer;gio;ven;sab;dom';

Directory;

SET vYearMonth=201302;

LOAD @1

FROM

[aaa_$(vYearMonth)_bbb.csv]

(txt, unicode, no labels, delimiter is '\t', msq);

SET vYearMonth=201303;

LOAD [03/01/2014 13:39:22:      Execution started.]

FROM

(txt, unicode, embedded labels, delimiter is '\t', msq);

kiranmanoharrode
Creator III
Creator III

Dear Daniel,

Insert single quotes around your variable. this may work.

FROM

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Regards,

Kiran Rode

+91 897 6977897

Not applicable
Author

Hi,

I would do:

FROM

  ‘X:\source\CH_$(vYearMonth)_Report.csv’

Fabrice

danieloberbilli
Specialist II
Specialist II

Did you check whether vYearMonth gives the right output? Maybe you have to transform it e.g. with num() to get the right outcome.

Not applicable
Author

Hi,

You are right, I didn't check the error correctly, the variable output was not what I wanted so it didn't find the file.

Thanks & regards.