加载具有不同 headers 的多个文件
Load multiples files with different headers
我已成功使用此脚本从多个文件加载数据:
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='janv.;févr.;mars;avr.;mai;juin;juil.;août;sept.;oct.;nov.;déc.';
SET DayNames='lun.;mar.;mer.;jeu.;ven.;sam.;dim.';
Data:
LOAD *, SubField(FileName(), '-', 1) as Regul, FileName() as fileName FROM
[P:\Some\Path\*.csv]
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
效果很好。
现在我想加载具有不同 header 名称的文件,假设 file A
得到以下内容:
HeadA | HeadB | HeadD
0 | 33 | 72
和File B
:
HeadB | HeadC | HeadD
60 | 40 | 30
我喜欢 QlikView
将其解释为:
Headers: HeadA | HeadB | HeadC | HeadD
FileA: 0 | 33 | null | 72
FileB: null | 60 | 40 | 30
有没有办法做到这一点(当前脚本挂起 12 小时,只有 60ko 的数据...)?还是我必须手动合并我的 headers?
concatenate load ...
函数将执行您想要的操作。
诀窍是用你不会首先使用的列创建一个虚拟 table(这样它在你可能使用的任何列中都会有空值)然后让 *.xls部分 run.Ifthe 额外的行打扰了您 您可以 运行 在完成后再次通过 table 并应用 where isnull(NotTheHeader)
子句
Data:
load 1 as NotTheHeader AutoGenerate(1);
Concatenate
Load *, SubField(FileName(), '-', 1) as Regul, FileName() as fileName from
[P:\Some\Path\*.csv]
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
我已成功使用此脚本从多个文件加载数据:
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='janv.;févr.;mars;avr.;mai;juin;juil.;août;sept.;oct.;nov.;déc.';
SET DayNames='lun.;mar.;mer.;jeu.;ven.;sam.;dim.';
Data:
LOAD *, SubField(FileName(), '-', 1) as Regul, FileName() as fileName FROM
[P:\Some\Path\*.csv]
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);
效果很好。
现在我想加载具有不同 header 名称的文件,假设 file A
得到以下内容:
HeadA | HeadB | HeadD
0 | 33 | 72
和File B
:
HeadB | HeadC | HeadD
60 | 40 | 30
我喜欢 QlikView
将其解释为:
Headers: HeadA | HeadB | HeadC | HeadD
FileA: 0 | 33 | null | 72
FileB: null | 60 | 40 | 30
有没有办法做到这一点(当前脚本挂起 12 小时,只有 60ko 的数据...)?还是我必须手动合并我的 headers?
concatenate load ...
函数将执行您想要的操作。
诀窍是用你不会首先使用的列创建一个虚拟 table(这样它在你可能使用的任何列中都会有空值)然后让 *.xls部分 run.Ifthe 额外的行打扰了您 您可以 运行 在完成后再次通过 table 并应用 where isnull(NotTheHeader)
子句
Data:
load 1 as NotTheHeader AutoGenerate(1);
Concatenate
Load *, SubField(FileName(), '-', 1) as Regul, FileName() as fileName from
[P:\Some\Path\*.csv]
(txt, codepage is 1252, embedded labels, delimiter is '|', msq);