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

ロードスクリプトでフッター数行を無視する方法

ロードスクリプトでデータソースを読み込む際、

ヘッダーサイズを「行:15行目まで」 のように、無視する先頭行数を指定することができますが、

似たように末端から◯行を無視する。といった指定は可能でしょうか?

 

先頭から15行を無視する

LOAD [ga:sourceMedium], 
[ga:pageviews]
FROM
[query_explorer_2019*.tsv]
(txt, unicode, embedded labels, delimiter is '\t', msq, header is 15 lines);

 

読み込ませたいファイルの例

Report For View (Profile): 	test.com

These results do contain sampled data.

These query parameters were used:
max-results	1000
dimensions	ga:sourceMedium
start-date	2019-07-01
start-index	1
ids	ga:10000
metrics	ga:pageviews
samplingLevel	HIGHER_PRECISION
filters	ga:pagePath=~^/completion
end-date	2019-07-01

ga:sourceMedium	ga:pageviews
(direct) / (none)	500
google / organic	200
yahoo / organic	120

Rows Returned	1000
Rows Matched	3
Totals For All Rows Matched
		820

 

末端から6行はデータとして無視したいと考えています。

 

例のデータが、日別に複数ファイル存在し、

「先頭から15行目」および「末端から6行」は無視する対象ですが、

その中間に何行入るかはファイル(日)によって変わります。

 

この部分だけを扱いたいというケースになります。

ga:sourceMedium	ga:pageviews
(direct) / (none)	500
google / organic	200
yahoo / organic	120

 

2 Solutions

Accepted Solutions
ShoNakajima
Employee
Employee

添付のqvfでいかがでしょうか。読み込みファイルにRowNoを入れ、Where句でRowNoの最大値から不要な行数を引いたものをロードしています。

 

#データは以下投稿いただいたのものをtsvファイルにして読み込んでいます。

読み込ませたいファイルの例

Report For View (Profile): 	test.com

These results do contain sampled data.

These query parameters were used:
max-results	1000
dimensions	ga:sourceMedium
start-date	2019-07-01
start-index	1
ids	ga:10000
metrics	ga:pageviews
samplingLevel	HIGHER_PRECISION
filters	ga:pagePath=~^/completion
end-date	2019-07-01

ga:sourceMedium	ga:pageviews
(direct) / (none)	500
google / organic	200
yahoo / organic	120

Rows Returned	1000
Rows Matched	3
Totals For All Rows Matched
		820

 

View solution in original post

hka
Employee
Employee

削除する下部6行の文字列が変化しないのであれば、以下のwhere句を加えてもらえればできると思います。

where not [ga:sourceMedium] like 'Rows*' and not [ga:sourceMedium] like 'Totals*' and len([ga:sourceMedium])>0;

View solution in original post

5 Replies
chakiw5
Contributor III
Contributor III

末から何行削除は自分は知りませんが、必要な行以下に対し条件付き削除を行えば可能かと思います。

ウィザードでヘッダーを設定→変換オプションを有効にする→条件付き削除

ここで列に対しどのような条件の行を削除するか設定します。

ファイルを添付しますので参考にしてください。

 

ShoNakajima
Employee
Employee

添付のqvfでいかがでしょうか。読み込みファイルにRowNoを入れ、Where句でRowNoの最大値から不要な行数を引いたものをロードしています。

 

#データは以下投稿いただいたのものをtsvファイルにして読み込んでいます。

読み込ませたいファイルの例

Report For View (Profile): 	test.com

These results do contain sampled data.

These query parameters were used:
max-results	1000
dimensions	ga:sourceMedium
start-date	2019-07-01
start-index	1
ids	ga:10000
metrics	ga:pageviews
samplingLevel	HIGHER_PRECISION
filters	ga:pagePath=~^/completion
end-date	2019-07-01

ga:sourceMedium	ga:pageviews
(direct) / (none)	500
google / organic	200
yahoo / organic	120

Rows Returned	1000
Rows Matched	3
Totals For All Rows Matched
		820

 

ShoNakajima
Employee
Employee

他の方が投稿されているように、QlikViewでしたら変換ウィザードでスクリプトを書かずに行削除ができるので、そこだけQlikViewで実行させ、生成されたロードスクリプトをQlik Sense側で使うという手も便利です。ただし公式Help上では推奨されていませんので予めご注意ください。

https://help.qlik.com/ja-JP/sense/April2019/Subsystems/Hub/Content/Sense_Hub/Scripting/functions-sta...

hka
Employee
Employee

削除する下部6行の文字列が変化しないのであれば、以下のwhere句を加えてもらえればできると思います。

where not [ga:sourceMedium] like 'Rows*' and not [ga:sourceMedium] like 'Totals*' and len([ga:sourceMedium])>0;

KenK
Contributor II
Contributor II
Author

ありがとうございます。

RowNo() as RowNo

で行数を入れ、

demo:
NoConcatenate Load *
Resident temp
Where [RowNo] < NoOfRows('temp')-3;

drop Table temp;

 

で-3行を削る方法が万能で、他のケースでも使用できますね。

ありがとうございます。こちらで解決しました。