Groups
Groups
Sign in
Groups
Groups
QGIS初心者質問グループ
Conversations
About
Send feedback
Help
フィールド計算機を使った文字の置換方法
3,627 views
Skip to first unread message
sakuya_izayoi
unread,
Jan 24, 2019, 1:26:08 AM
1/24/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
こちらizayoiです。お世話になります。
フィールド計算機を用いた、文字の置換方法があれば知りたいです。
フィールド名[text]というフィールド内に
ウソ
ウソ
ウソ
ウソ
ホント
ホント
ホント
ホント
ホント
という列があります。
その「ウソ」という文字列を「未検証」という風に置換したいという意味合いです。
GeoCSVにした後にテキストエディタで置換するというのも手なのですが、フィールド計算機でも可能なのかと思い質問させていただきます。
きた
unread,
Jan 24, 2019, 1:34:29 AM
1/24/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
フィールド計算機のIF関数でもできますし、属性テーブルで「ウソ」でフィルタをかけてデータを選択して、編集モードにして、更新するフィールドを選択し、テキストボックスに「"未検証"」と入力し、選択のみ更新でもできます。
きた
adachi
unread,
Jan 24, 2019, 1:39:09 AM
1/24/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
izayoi様
replaceという関数が使えるかと思います。
replace("text", 'ウソ', '未検証')
「text」フィールドをそのまま更新したい場合、新たにフィールドを作成する場合どちらでも
上の式で「ウソ」が「未検証」に置き換わります。
文字列の一部のみを置換することも可能です(「ウソ」→「ウシ」など)。
※ダブルクオーテーション、クオーテーションの違いに注意してください
Message has been deleted
sakuya_izayoi
unread,
Jan 24, 2019, 1:56:23 AM
1/24/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
きた さま
なるほど。数がそこまで多くない(フィルタをかけて動いてくれる場合)はこれが楽ですね。
そうか。if("text", 'ホント', '未検証') の構文でいけちゃうか。case whenで考えていて複雑化させていました。
一瞬で計算できた・・・と思いきや、大失敗。
そうか今回は
replace("text", 'ウソ', '未検証')
の方が都合良いのか。
良いヒントありがとうございます。
sakuya_izayoi
unread,
Jan 24, 2019, 1:58:09 AM
1/24/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to QGIS初心者質問グループ
adachiさま
すみません。QGIS弄って書きこんでいる間にお答えいただいたようで。
同じ構文となり安心しました。
新しいフィールドをわざわざ作らなくても良いのか。これは良い。データがただでさえ重たいので、列数増やしたくなかったのでありがたいです。
Reply all
Reply to author
Forward
0 new messages