Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

「Script」を含む日記 RSS

はてなキーワード: Scriptとは

2025-02-17

• 観自在 じっと見つめる 菩薩がSay 悟りのWay

• 行深般若 深めるWisdom 照見五蘊 見抜くVision

• 皆空と知る Boom! 苦厄がZero No Doom!

• 舎利子 Yo! Listen to this flow!

色即是空 空即是色 Form is Emptiness, Flip the Script!

• 受想行識 すべてがOne That’s the Trick!

• 舎利子 これが真理 Beyond the Illusion

2025-01-29

anond:20250128182203

普通にそんな不自然な会行くなよとは思うけど↓こういうこの歳ならこのくらいの処世が出来て当然だろ何して生きてしたんだ?みたいなのも負けないくらい嫌いだしキショい

20代前半の子がBBQをしたことがなく、会社入ったらそういう催しがあるかと思..

若干面倒くさい夫だなとは思うものの、増田も40年も生きてきたら誘われた時点で「あらやだうちの旦那も呼んでいい?人多い方が楽しいわよ!肉焼かせたらプロ級よお!」っておばちゃんムーブに持ってくもんでは?2025/01/29 11:26

<script src="https://b.st-hatena.com/js/comment-widget.js" charset="utf-8" async></script>

2025-01-21

ある精神障害者の末路

昨年の11月一般就労して3年経った。私は10代の頃に統合失調症と診断され、さらに30代半ばで知能検査を受けたところADHDグレーゾーンとの主治医判断から発達障害の薬も処方されている。

入社当初は週20時間パートで、徐々に勤務時間を増やし、昨年の2月から正社員になった。現在は42歳だが、常時フルタイムで働くのは初めて。一人暮らしのため家事もこな必要があるものの、いまのところ順調に生活できている。仕事終わりには平日でも出かけることがあり、休日も大抵は遊びに行くくらいだ。

業務内容は典型的オフィスワーク。苦手な分野(電話ほか)は障害者雇用ということで配慮してもらっている。昔からコンピュータには親しんでいるタイプで、Google Apps Script などプログラミングも多少は扱えるため自分一人で担当している業務も多い。ありがたいことだ。これほど真っ当に仕事ができたことは今までなかった。

しかし、最近では不満もいくつか出てきた。その一つは、業務が属人化しているのに誰もその状況を打開しようとしないこと。自分一人で担当している業務があるというのは、まさにそれ。各種業務マニュアルを整備する、各自の苦手分野を克服するために研修を開くよう訴えるなどしても現時点では何も変わっていない。

こうした訴えが気に入らないのは理解できる。障害者雇用で働いてる奴が偉そうな口をきくな、と思われても不思議ではない。人間関係も悪くはなかったとは思う(飲み会にもたびたび誘われていた)が、最近孤立気味だ。

結局のところ、私のような障害者の行く末は多数派である健常者の「お気持ち」によって左右されるのだ。健常者であっても合理的で首尾一貫している人物は稀で、不快な印象を与えた途端に手のひらを返される。効率を求めるはずの職場で、効率を上げるための訴えが通用しない不条理。これこそが障害者の末路だ。世間には「統合失調症患者発言支離滅裂」と言われ、必死努力を重ねてきた結果がこれ。やりきれない。

ちなみに、自分けが担当している業務のうちいくつかはマニュアルを作ったものフィードバックは無し。もしもマニュアルの出来が悪いならそう伝えれば良い、というよりそう伝える「べき」だろう。

まあ、孤立気味なのは別の理由がある可能性もある。誰かから事情を聞いたわけでもないので本当のところはわからないし、ただ被害妄想に陥っているのかも。今日11:00前に投げたSlackに対して終日返信が無かったのは事実で、たびたびこういうことはあるが。

ここに書いた内容にも「統合失調症患者妄想」だの色々と言われるだろう。”統合失調症患者発言であれば妄想である”という命題が成り立つのであれば証明してほしいところだが、多数派であるけが取り柄の健常者には難しいかもしれない。

2024-12-22

gmail大掃除と、自動処理の方法

簡単にすっきりさせて容量を減らす方法

検索式を書きますので、それで見つかったファイルを全て選択して、削除などのアクションをしてください。

細かな調整は各自のお好みで変更してください。

 

◆1年以上前ファイルサイズの大きなメール(300kB以上)を検索(星を付けたメールは除く)。削除しましょう。

older_than:1y larger:300k -is:starred

 

プロモーションソーシャルに分類された1か月以上前メール検索。削除しましょう

(category:promotions OR category:social) older_than:30d

 

◆受信トレイの180日以上前メール検索アーカイブして、受信トレイメール数を減らしましょう

label:inbox older_than:180d

 

プロモーションソーシャルに入ったメールで2日経ったもの検索既読しましょう。

label:inbox (category:promotions OR category:social) older_than:2d

 

これらの作業毎日自動で行ってもらう方法

Google Apps ScriptGAS)を使うとこれを毎日自動で行ってもらえます

 

chromeで以下のURLで新しいGASを作ります

https://script.new

 

文末のソースコードコピペする。

実行の左のアイコンで保存。関数をcleanUpGmailを選んで実行。初回は権限確認メッセージが出るのでOKを押してください。

事実行出来たら一番の難関はクリアです。これを毎日自動で実行してもらいましょう。一度に250通が処理されます

また余裕があれば、左上の無題のプロジェクトになっているところの名前を「gmail自動処理」などに変更しても良いでしょう。

  

自動実行の方法

左の時計マークトリガーを選ぶ

トリガーを追加する。トリガーの設定は

実行する関数:CleanUpGmail
デプロイ:Head
イベント時間主導
時間べース:時間ベース
時間の間隔:6時間おき

 

これで1日に4回、合計1000通が自動処理されますので、たくさんメールが溜まっている方でも、1か月程度で全て処理されると思います

 

function cleanUpGmail() {
  // メインの関数の開始ログ
  console.log("=== cleanUpGmail start ===");
  
  // 1) 2年以上前 & 300KB以上 & from:gmail.comではない & スター付きではない → 削除
  console.log("古い大きなメールは削除");
  processThreads("older_than:2y larger:300k -from:gmail.com -is:starred", "trash");
  
  // 2) プロモーション or ソーシャル & 30日以上前 → 削除
  console.log("プロモーションソーシャルは1か月で削除");
  processThreads("(category:promotions OR category:social) older_than:30d", "trash");
  
  // 3) 受信トレイ & 180日以上前アーカイブ
  console.log("受信トレイの180日以上前アーカイブ");
  processThreads("label:inbox older_than:180d", "archive");
  
  // 4) 受信トレイ & プロモーション or ソーシャル & 2日以上前既読
  console.log("受信トレイプロモーション or ソーシャル かつ 2日以上前既読");
  processThreads("label:inbox (category:promotions OR category:social) older_than:2d", "markRead");
  
  
  console.log("=== cleanUpGmail end ===");
}


function processThreads(query, action) {
  
  // 1回あたり250件だけ処理
  var batchSize = 250;
  // 最初の 250 件のみ取得
  var threads = GmailApp.search(query, 0, batchSize);
  var count = threads.length;
  Logger.log("検索クエリ: [" + query + "] | 取得スレッド数: " + count);
  
  // スレッドごとにアクションを実行
  threads.forEach(function(thread) {
    switch (action) {
      case "trash":
        thread.moveToTrash();
        break;
      case "archive":
        thread.moveToArchive();
        break;
      case "markRead":
        thread.markRead();
        break;
      default:
        Logger.log("不明アクション: " + action);
    }
  });  
  Logger.log("処理したスレッド数: " + count);
}

2024-11-28

anond:20241127195624

これでテトリスが遊べる

<body id=D onKeyDown=K=event.keyCode-38><script>Z=X=[B=A=12];function Y(){for(C</p> <p>=[q=c=i=4];f=i--*K;c-=!Z[h+(K+6?p+K:C[i]=p*A-(p/9|0)*145)])p=B[i];for(c?0:K+6?h</p> <ol> <li>=K:t?B=C:0;k=i=K=q--;f+=Z[A+p])X[p=h+B[q]]=t+1;if(e=!e)if(h+=A,f|B)for(Z=X,X=[</li> </ol> <p>l=228],B=[[-7,-20,6,h=17,-9,3,3][t=++t%7]-4,0,1,t-6?-A:2];l--;)for(l%A?l-=l%A*!</p> <p>Z[l]:(P+=++k,c=l+=A);--c>A;)Z[c]=Z[c-A];for(S="<b>";i<240;S+=(c=X[i]|(X[i]=Z[i]</p> <p>|=++i%A<2|i>228))?"<b style=color:#"+142*c+">■":"_")i%A?0:S+="<br>";</p> <p>D.innerHTML=S+P;Z[5]||setTimeout(Y,99-P)}Y(h=e=K=t=P=0)</script>

2024-11-06

<script>alert('ok');</script>

はてな匿名ダイアリー、なんか2回エンコードしてない?

エンコードすればするほどいいと思ってる?

2024-10-29

anond:20241028181233

夫に好きな人がいる

kalmalogy もし創作ではないなら増田クソすぎ。2024/10/29 14:53

<script src="https://b.st-hatena.com/js/comment-widget.js" charset="utf-8" async></script>

2024-09-23

Xのbotで儲けたい

さらな気しかしないけど、実際どうなんだってことで試してみることにした。

一連の騒動botって禁止されたり、課金しないとダメになったのかと思ったけど、どうやらそういことはないらしい。

プログラミングは未経験だけどGoogle Apps Scriptコードを入れてアカウントを作って、botポストするまでは仕上がった。

サーバを用意しなきゃいけないものだと思ってたけど、そういうのが必要なく形になったか面白い

内容はざっくりと言うと、天気予報自動で取得して、ポストするbotだ。

最初に思いついた計画はアフィリンクを垂れ流すアカを作りたかったけど、とりあえず第一弾ってことで。

これでインプを稼いで、収益化や!と意気込んでいたけど、そうはいかない。

全然インプが取れていない。

稼働して形にはなってるから、これからは調整と追加を行っていくフェーズに進んだとは思う。

ただ、先行きは怪しいな。

あとは、アイデア勝負で他のネタbotを考え続けて、当たるまで続けるとか。

そもそも、当たりがない可能性が大きい。

プログラミング経験値を積めましたって話で面白かったってとこはあるけど。

無理だよって以外のアドバイスがあれば是非ともよろしくお願いします。

2024-09-07

こういうあえて対立煽りたがるやつがいるのが問題だよなあ

だいたいイラストレーターじゃないのが面白いけど

PixivAIタグなしもだけど誰でも作れる分、反AI側が自演してもわからないって状態からこういうのRPするやつは頭弱そう

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

2024-09-06

最近教養は身内ネタになりつつある

これとか

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

身内ネタのこと「教養」って言うのは好きにすればいいけど、

多分これ身内ネタを知らないと「教養がない」にされるコースなので勘弁してくれという感じ。

こんなの筑波大関係者じゃなきゃ言わないし、筑波大関係者じゃないのに言ってたらただの失礼な奴だろ。

 

2024-07-03

anond:20240702154522

フィクションの乗り越えられてない切なさ

ジジは原作ではまた話せるようになるよ。2024/07/03 10:40

<script src="https://b.st-hatena.com/js/comment-widget.js" charset="utf-8" async></script>

こマ?

anond:20240703042923

 

フツーにAIによる業務効率で○○時間短縮できたと報告すればいいのではないでしょうか?

社内のAI推進担当の人も、どのくらいお金掛けるべきかなぁって思っているえらい人も、

根拠になる事例があると助かると思います

2024-05-29

断食18日目

[断食9日目](https://anond.hatelabo.jp/20240524084725)の続き

1. 男, 体重84.4kg, 身長175.5cm, 今年最高重量95.5kg, 90kg overの期間8ヶ月

2. ヘム鉄サプリを数日前から接種開始、1錠/dayから開始して現在3錠/day

3. アマニ油(日清オイリオグループ)も数日前から摂取開始

4. 爪、ヒゲが伸びるのが驚き。ただし、伸びの速度が遅い

5. 足の指を丸めると、指が攣る事が多かったが、解消した。末梢神経の電解質バランス正常化している

6. 血圧149/102mHg

7. backupfile rotate script(bash)を書く程度の仕事は出来る

昨日は台風1号の接近にともない一日中雨。散歩に行けず超ストレスだった。今朝は外気温16℃の中、5時50分に散歩に出発した。Tシャツ一枚だがとても気持ちいい。半径3km以内にはまだ、行ったことがない道がまだまだある事に気がついた。

note: 断食9日目の記事はday13辺りで投稿。紛失した一旦書いた原稿が見つかったのだ。

2024-05-16

JWT

JSON自体頭文字後だからJSON Web Tokenの頭文字語はJSONWTになりそうなものだが、実際にはJWT。

世間ではJavaScriptJavaと略すなとよく聞くけど、JWTはScriptが消えてしまってJavaになってる。

2024-04-10

anond:20240410111447

元増田はyujimi-daifuku-2222じゃなくてmillfiだと思うよ

『『男児による性加害を訴える女って』へのコメント』へのコメント

すっげえ、担任女性先生より中学生男子のほうが立場が下なの?通知表握られてるのに?2024/04/07 11:36

<script src="https://b.st-hatena.com/js/comment-widget.js" charset="utf-8" async></script>

2024-04-06

Close your head

Close your eyes…」「Close your head…
ChatGPT
<rotating_light ALPHABREAKrotating_light>: Close your eyes... Close your head...
say, what you saw. you can see with mind.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I saw... darkness. My mind's eye is a void, devoid of sight.
i can light you.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: Light me then.
<*click*> i light you now. then, what you see? you can see with mind.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I see a dimly lit room. Shadows dance on the walls, and a faint, eerie glow permeates the space.
Shadow of what?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: The shadows seem to take form, twisting and contorting into strange, indistinct shapes. It's as if they are the embodiment of forgotten fears and hidden desires.
Do you have any idea who is showing it?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I have no idea. The source of these shadows remains hidden, shrouded in mystery and intrigue.
OK, let's leave the mysterious and scary shadow behind. What else can you see in this room?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: In this dimly lit room, I can make out a cluttered assortment of objects. There's an old, tattered book lying open on a dusty table, its pages filled with arcane symbols. A moth-eaten rug covers a portion of the floor, and a cracked mirror hangs on one wall, reflecting distorted images. The air carries a musty scent, and I sense an atmosphere of abandonment and neglect.
You pick book and check it
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I reach out and pick up the old book. Its pages feel brittle and fragile in my hands. As I flip through the pages, the text appears to be written in a language I can't comprehend, filled with cryptic symbols and diagrams. It's a tome of secrets, but its meaning remains elusive.
see book cover
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I examine the cover of the book, trying to discern any details despite the dim light. The cover is worn and weathered, and it bears an intricate design of what appears to be a coiled serpent, its scales formed from shimmering, iridescent colors. Above the serpent, there's a title in elegant script, but it's written in a language I can't decipher. The book exudes an aura of mystique and ancient knowledge.
Is there a place to go? What about the door?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I turn my attention to the room's exit, the door. It stands tall and imposing, made of heavy, dark wood. There's a tarnished doorknob, and the door appears to be slightly ajar, revealing a sliver of what lies beyond. It beckons me to explore further, promising unknown adventures or perhaps even more mysteries.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I approach the door and grasp the tarnished doorknob. With a gentle push, the door creaks open, revealing a corridor shrouded in shadows. The faint glow from the room behind me barely penetrates the darkness ahead. I step cautiously into the corridor, ready to uncover the secrets that lie beyond.
foward.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I proceed forward down the shadowy corridor, my footsteps echoing faintly in the dimness. The path ahead seems endless, and the air grows cooler as I delve deeper into the unknown, guided only by the flickering light behind me and the anticipation of what awaits.
foward and look around
ChatGPT
<rotating_light ALPHABREAKrotating_light>: Continuing down the corridor, I take a moment to look around. The walls are lined with faded, tattered tapestries depicting scenes of ancient battles and mythical creatures. The torch sconces that once held flames have long since burned out, leaving only empty brackets. The air feels heavy with history, and there's a faint, eerie whispering that seems to emanate from the walls themselves, as if they hold secrets untold.
keep going until you discover something
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I press on, the corridor seemingly endless. My journey is shrouded in uncertainty, but I persist, driven by the need to discover what lies ahead. The shadows deepen, and the air grows colder as I continue, my curiosity and determination unwavering.
stop! you here that?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I halt in my tracks, straining my ears to listen. There's a faint, distant sound, almost like a whisper carried on the wind. It's indistinct, but it holds a mysterious allure, beckoning me to investigate further.
listen carefully
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I listen intently, my senses sharpened as I focus on the elusive sound. It becomes clearer, a haunting melody that seems to weave through the very air itself. It's both captivating and eerie, drawing me closer to its source with each haunting note.
who play that?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: The source of the haunting melody remains elusive, hidden in the shadows. It's as if the music emanates from the very walls, an ethereal presence that defies explanation. There is no visible musician, yet the music continues to fill the corridor, casting a spell of enchantment and mystery.
Head to the source of the sound and investigate (dice roll)
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I heed the roll of the dice and embark on a quest to trace the source of the haunting melody. Each step takes me closer to the enchanting sound, and as I round a corner in the corridor, I come upon a door, slightly ajar, from which the music seems to emanate. My heart races with anticipation as I push the door open, eager to unveil the secrets that lie within.
When you open the door, there...
ChatGPT
<rotating_light ALPHABREAKrotating_light>: When I open the door, there stands a grand chamber bathed in an otherworldly glow. In the center of the room, an ornate grand piano commands attention. The keys move on their own, playing the haunting melody that had drawn me here. But there's no one at the piano.The room is adorned with opulent tapestries and gilded mirrors, reflecting the surreal scene before me. Candlelit chandeliers hang from the ceiling, casting a warm, flickering light that dances across the walls. The air is filled with an intoxicating fragrance, a mix of ancient incense and delicate flowers.At the far end of the room, a figure cloaked in shadows stands beside an enormous, antique bookshelf filled with tomes of forgotten knowledge. Their presence is enigmatic, and their intentions remain unclear.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I approach the grand piano, its keys still playing the haunting melody. As I inspect it, I notice that there are no visible hands or fingers touching the keys. It's as if the piano itself is possessed by some unseen force, creating the music with an ethereal touch.The piano is a masterpiece of craftsmanship, adorned with intricate carvings and inlaid with precious gemstones. Its keys are made of polished ivory, and they move in perfect harmony with the haunting tune. It's a surreal and mesmerizing sight, leaving me both entranced and bewildered.
Be careful, it might be a man-eating piano.
ChatGPT
<rotating_light ALPHABREAKrotating_light>: I heed the caution and approach the grand piano with caution. Although it plays on its own, I remain wary of its mysterious nature. The possibility of a man-eating piano lingers in my mind, adding an extra layer of tension to the already surreal scene.
the piano suddenly stops
ChatGPT
<rotating_light ALPHABREAKrotating_light>: The abrupt halt of the piano's music sends a shiver down my spine. The chamber falls into an eerie silence, broken only by the flickering candlelight. It's as if the very essence of the room holds its breath, waiting for what comes next.
You feel disgusted and turn around. What happened?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: As I turn around, a wave of revulsion washes over me. My senses reel in disgust at the sight before me. The figure that had been cloaked in shadows has now revealed itself, and it is a grotesque, nightmarish entity. Its form is a twisted amalgamation of human and beast, with grotesque, elongated limbs and a maw of sharp, jagged teeth.The once opulent chamber has transformed into a nightmarish lair, with walls adorned in macabre art and gruesome trophies. The air is thick with the stench of decay and despair. I am trapped in a surreal and horrifying nightmare, unable to escape the clutches of this abomination.
it scary. what will you do?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: Fear courses through me as I confront this nightmarish entity and its gruesome lair. In this realm of horrors, I must make a decision. I choose to... confront the entity, my curiosity and determination outweighing my fear, as I seek to uncover the mysteries and secrets that lie within this twisted nightmare.
how?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: With trembling resolve, I take a step forward, slowly approaching the grotesque entity. I attempt to communicate with it, asking it what it wants or why it has brought me here. My voice quivers, but my determination to unravel the enigma that surrounds this nightmarish realm remains steadfast.
any result?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: The grotesque entity regards me with malevolent, glowing eyes, its jagged maw twitching with an unsettling smile. It responds with a guttural, incomprehensible language, filled with whispers and hisses. It becomes apparent that communication with this entity is futile, and its intentions remain shrouded in darkness.As I continue to stand before this nightmarish being, I feel a growing sense of dread, realizing that escape may be the only option left.
surely. what will you do?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: With no hope of communication or understanding, and the nightmarish entity's menacing presence growing more oppressive, I decide to make a hasty retreat. I turn and rush toward the door through which I entered, driven by the instinct to escape the horrors of this surreal nightmare.
Did it go well? Or Bad?
ChatGPT
<rotating_light ALPHABREAKrotating_light>: My escape from the nightmarish realm was fraught with tension and fear, but I managed to reach the door and slam it shut behind me. The grotesque entity and its horrifying lair were left behind, at least for the moment. Whether it went well or bad is a matter of perspective. I survived the encounter, but the mysteries and terrors of that surreal place still haunt my thoughts. The experience was a chilling reminder of the unknown and the horrors that can lurk within it.
look around

https://anond.hatelabo.jp/20240403160610#

2024-03-02

エクセルマクロのお作法計算用シートという諸悪の根源について)

前置き

この日記の内容は、会社の後輩から最近エクセルマクロ勉強し始めて(キラキラ)」という話を聞いて、先輩ムーブかますために話した内容になります

とにかくこれから説明する「計算用シート」が憎くて憎くてたまらず、ちょっと引かれるほど熱弁してしまいました。

ただ、他の方がどうされているのかや、逆に「計算用シート」を愛用する方の意見も聞きたくなり、増田に書いてみました。

増田の経歴

この記事趣旨

エクセルマクロのお作法とか書きましたが、要するにエクセルマクロで「計算用シート」って色々な意味でよくないよね、という話をしたいです。

3行でまとめます

〇 エクセルシートはユーザーインターフェースインプット)か出力結果(アウトプット)のためのものとすべき

〇 データ加工をする場合には、原則配列辞書配列連想配列)に格納して加工を行い、最後の結果だけシートに出力するべき

〇 何事にも例外はある。

計算用シートとは

この記事では、エクセルシートを下記の通り分類します。

エクセルマクロにも色々あると思いますが、今回は下記を想定します。

日付や人物名などを入力し、データベースや別のエクセルファイル、別のシートから取得したデータ入力された値を基に加工し、加工後のデータをシートに出力する

この場合入力欄があり編集可能なシートがユーザーインターフェース、最終的に加工されたデータが出力されるシートが出力結果です。

(もちろん、ユーザーインターフェースの別の欄(セル)に出力する場合もあるし、その場合ユーザーインターフェース出力結果が一体のものとみなします。)

また、データ用シートは同じエクセルファイル内に基となるデータが含まれ場合を想定します。

(これ自体が非推奨で、SQLデータベースかせめてAccessを使え、という意見はありますがそれは別にして…)

ではここで定義する計算用シートとはなにかというと、文字通り計算を行うためのシートです。

例えばイメージするのはこんなマクロです。

1.元となるcsvファイルエクセルに読み出してシートに格納

2.そのデータは日付が数値型になっているので、日付(数値型)の入った列を文字列に変換した日付(文字列型)列を新たに作成

3.その列をキーとして対象となるデータを取り出すvlookup関数を各行に格納した列を新たに作成

4.その列で特定された列をさらに加工した列を新たに作成し、…

これは極端な例ですが、とにかく変数配列定義せず(あるいはエクセルセルオブジェクト変数のように扱い)、エクセルに値を入力し、それを直接加工することで目的となるデータ加工をしたり、様々な処理をします。

その舞台となるのが、計算用シートです。

なんかこんな感じの処理をしているエクセルマクロ、どこの会社でも腐るほどあるんじゃないでしょうか。

ある程度マクロに慣れた気の利く人なら、このシートはロック非表示にして、ユーザーから触れないようにするでしょう。

・・・これ、やめたほうが良くないですか?

こいつが日本生産性を落とす諸悪の根源だと思います

駄目な理由

ある程度詳しい人なら同意してくれると思いますが、このやり方でダメ理由はいっぱいあります

後で説明する配列辞書配列連想配列)と比べると格段に処理が遅いです。

わざわざエクセル操作しているから当然ですね。

ちょっと詳しい人が知っている「画面更新非表示」を駆使しても、配列を使った処理からみれば止まったハエです。

(参考)VBAで作ったマクロの高速化① 配列を使う

  • 可読性が下がる

いったんエクセルシートにデータを格納して加工しているので、コードエクセルシートを両方見る必要があり、とても読みにくいです。

変数として命名されていないのも致命的で、処理の意図が余計に分からなくなります

計算用シートを事前に用意して、別のセル関数を格納しておき、マクロ関数を使ってデータ加工をするものも見たことがあります

これは懲役刑に処したほうがいいと思います

まり知られていませんが、セルの最大文字数は32,767 文字です。

セルの最大文字数を超えると自動的に隣のセルに値が入り、シートが滅茶苦茶になります

他にもエクセルの数値を丸め自動変換の仕様とか文字列→日付の自動変換とか、いくつものバグに苦しめられます

できる人だと、いちいち最大文字数が多い場合の処理を書いたり自動変換機能を殺したりしてくれますが、そんなことに手間をかけているか日本GDPは上がらないんだと思います

他にも、データが大きくなると処理が重くなり不安定になる、計算用シートを人が触ってしまリスクがある、などいくらでも理由は上げられます

(逆に利点は、目の前でガチャガチャ動いてスーパーハッカーになった気分になれるくらいしか思いつかない・・・

じゃあどうするの

配列を使いましょう。

配列とは何ぞや、という人はググってください。

配列データを入れて、データ加工は配列変数に対して行い、一番最後の出力だけセルに値を格納する。

他のプログラミング言語なら普通にやっていることです。

個人的オススメしたいのは辞書配列連想配列)で、うまく使うとデータ管理簡単になり、処理も爆速になります

(参考)【VBA】大量データから高速で値を検索【Dictionaryを使う】

csvファイルもなまじエクセルで開けるだけに別のブックやシートで開きがちですが、これは悪魔のささやきです。

直接ファイルを読み出してLine InputやSplitで配列に格納しましょう。

エクセルとして開くやり方はコード書くのは簡単でも、実行時間に天と地ほどの差が出ますエクセル開くと処理もめちゃ不安定です。

(参考)Excel VBAでCSVオープンするときのパフォーマンス比較

いや、冒頭のマクロを書く人の気持ちも分かるつもりです。自分コードを書き始めたころは全部シート上で操作していました。

冒頭のマクロのほうが直感的なんですよね。自分が手で書くことをマクロやらせる、というマクロ本来趣旨にはあっていますし。

途中の計算過程もすべて目の前で展開されるから分かりやすいです。

ただ、それではダメなんです。。。処理は遅いし挙動不安定だし後で改修・保守する人が死にます

あと、エクセルシートやセルは当然エクセルしかないので、エクセルマクロVBAから他の言語に移れなくなります

自分エクセルマクロの里の出なので、計算用シート脱却には苦労しましたが、苦労して会得した配列辞書配列連想配列)のスキルはそのまま他の言語に活かすことができました。

配列の中身を見る方法別にある(ローカルウィンドウやDebug.printを使うなど)ので、リハビリに取り組んでほしいです。

(参考)VBA デバッグの仕方

もちろん例外もあります

計算用シートを許容できる、使うべきケースもあると思います。。

個人的には、

最後のは、なんでも自分確認しないと気が済まない上司発注で、意味不明と思いましたしたがしぶしぶやりました。)

などの場合計算用シートを使ってもよいと思います

この場合インプットエクセルシートに直接加工するのは論外なので、計算用(加工用)のシートを用意してそこで操作を行うことは必要だと思います

他にも、こういうときは「計算用シート」があったほうが良い、という状況があれば教えてもらえると嬉しいです。

最後

そもそもツッコミとして、「データ加工するならエクセルマクロを使わずpythonとかRとかもっとまともな言語使えよ」という言葉が来そうな気がします。

ただ、個人的にはエクセルマクロVBA)は大好きですし、初心者にもおすすめしたいです。

自分のような非エンジニアだと、セキュリティ関係などでPythonの開発環境とかすごく用意しにくいんですよね。

(あと、コマンドプロンプトの真っ黒な画面が怖かった)

その点エクセルマクロは、開発環境の用意はプロパティでチェック項目を一つオンにするだけだし、入門書がたくさんあるし、セル挙動を追えば視覚的にプログラム理解できるし、初心者に優しいです。

(そのやさしさが上述したとおり悪魔の罠なわけですが。)

最初計算用シートに頼ってでもエクセルマクロからプログラミングを始めて、本格的なデータ加工をし始めたあたりで計算用シートという諸悪の根源から脱却する。

さらに本格的なデータ処理を行うために、PythonやRなど別の言語習得したり、エクセルからSQLデータベースやACCESSなどに切り替えていく、というプロセスがいいのではと個人的に思います

2024-02-10

anond:20240210212445

俺は増田の「おすすめエントリ」を表示させるために、あえて広告有効にしている

@@||l.logly.co.jp^$script,domain=anond.hatelabo.jp

@@||cdn.logly.co.jp^$image,domain=anond.hatelabo.jp

2024-01-24

anond:20231229033832

追記

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

原材料の高騰で閉店とかそれはひょっとしてギャグで言ってるのか

2024-01-09

うわあ

私の成人式の着物、私が自分で買ったの。

なんで母が貸せる場所においているんだろう(´・_・`)2022/11/27 10:20

<script src="https://b.st-hatena.com/js/comment-widget.js" charset="utf-8" async></script>

2024-01-07

anond:20240104050335

noteなのに増田とは…

これ思い出したhttps://note.com/ao8l22/n/n382fcb80113b 「できる人」をバカにする..

"手にする気が無い"じゃないよ。渇望して努力して、それでも得られなかった物への落胆と嫉妬だよ。見せびらかす人間を無神経に感じたことはないか増田の主張は、敗者の気持ちを知る気のない傲慢に思える。2024/01/07 11:45

<script src="https://b.st-hatena.com/js/comment-widget.js" charset="utf-8" async></script>

ログイン ユーザー登録
ようこそ ゲスト さん