VSCodeからCSVファイルをExcelで開く方法
VSCodeから直接 Excel を起動してCSVファイルを開く方法はいくつかあります。
① ターミナルからExcelを起動する(Windows)
方法 1: start
コマンドを使用
VSCodeのターミナル(PowerShell または コマンドプロンプト)で以下を実行
output.csv
は開きたいCSVファイルの名前- これでExcelが起動し、CSVファイルが開かれる
江端智一のホームページ
VSCodeから直接 Excel を起動してCSVファイルを開く方法はいくつかあります。
start
コマンドを使用VSCodeのターミナル(PowerShell または コマンドプロンプト)で以下を実行
output.csv
は開きたいCSVファイルの名前
Windows 11 に WSL2 をインストールし、Ubuntu をデフォルトOSに設定し、Docker をインストールする手順を説明します。
Docker for Windowsが、有償化されて、(現場が)困ったことになっています。
ChatGPTにDocker for Windows と Docker Desktop の違いについて教えてもらいました
で、これを回避する方法として、「WSLのLinuxを利用して、Dockerを利用する方法」がある、という話を聞き『あ、盲点』と思い、さっそく環境構築をノートPCでやってみました(本番PCでコケるのは怖かったので)。
管理者権限で PowerShell または コマンドプロンプトを開き、以下のコマンドを実行します。
wsl --install
これにより、WSL2 とともに Ubuntu が自動でインストールされます。
WSL のバージョンを確認するには
wsl --list --verbose
もし、既に WSL1 になっている場合、以下のコマンドで WSL2 に変更できます:
wsl --set-version Ubuntu 2
インストールされている WSL のディストリビューションを確認:
wsl --list --verbose
wsl --set-default Ubuntu
WSL2 上の Ubuntu に Docker をインストールします。
sudo apt update && sudo apt upgrade -y
sudo apt install -y docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
適用するには、一度ログアウトするか、以下を実行:
newgrp docker
docker run hello-world
「Hello from Docker!」と表示されれば成功です。
sudo apt install -y docker-compose
通常、Windows 上で Docker Desktop を使う方法もありますが、WSL2 内で直接 Docker を動かしたい場合は systemd
を有効にします。
sudo nano /etc/wsl.conf
以下の内容を追加:
[boot] systemd=true
保存して WSL を再起動:
wsl --shutdown
再度 WSL を起動して systemctl
が使えることを確認:
systemctl list-units --type=service
sudo systemctl enable --now docker
これで、WSL2 + Ubuntu + Docker の環境構築が完了しました。
これは、以下を参考にして下さい。
$ sudo docker load < 20240828_shajyo.tar
のあたりから続けます。
これをwslで実行すると、docker imageができます。
ところで、この段階で、ちょっと不思議なことが起こりました。
docker for windowsを起動すると、WSL内のdocker imageの名称が変わります(理由不明で、変なのですが、動くなら、まあ構いません)。
で、それだけでなく、docker imagesで、Docker for windowsのイメージが全部登場してきます。
なんだか良く分かりませんが、これが出てくるのであれば、「Docker for Windowsのコンテナイメージをtarで固めて展開する」をサボれるかもしれません(誰か確認したら教えて下さい)。
で、あとは、Docker for Windowsで作成した時と、同じディレクトリに移動して、
docker-compose restart
をすると、無事に動き出しました。
なんだか良く分かりませんが、Docker for Windowsを使っている環境であれば、それを残した状態で、この作業すると、随分手を抜けるかもしれません。
移行した後に、Docker for Windowsをアンインストールすれば良いでしょう。
お試しあれ。
言うまでもありませんが、無保証です。
Docker for Windows を起動すると、WSL 内で動作している Docker イメージの内容が変化する可能性があります。以下の理由が考えられます。
Docker for Windows(Docker Desktop)は、デフォルトで WSL 2 ベースのエンジン を使用します。
これにより、WSL 2 で管理されている Docker のデーモン(dockerd
)が Docker Desktop の管理下に入る ため、起動時に設定や状態が変更されることがあります。
Docker for Windows を起動すると、WSL 内の Docker の設定が次のように変わる可能性があります。
wsl -d Ubuntu
などで WSL 2 内の dockerd
を起動していた場合、Docker for Windows を起動すると Docker Desktop が管理するデーモンに切り替わる。docker
データストアの場所が C:\ProgramData\DockerDesktop\
に変更されることがある。~/.docker/
や var/lib/docker
に保存されていたイメージやコンテナが正しく認識されなくなる場合がある。Docker Desktop は Windows 側のネットワーク設定やストレージマウントを変更するため、WSL 側の Docker コンテナに影響を与えることがあります。
docker0
ブリッジの再設定や、NAT の適用によって WSL 内の Docker コンテナの通信方法が変わることがある。/mnt/c
のようにマウントしていたボリュームが、Docker Desktop の管理下で //wsl$/Ubuntu
経由でマウントされることがある。Docker for Windows の Settings
→ Resources
→ WSL Integration
で 「Enable integration with my default WSL distro」 を有効にすると、
Docker のデフォルトデーモンが WSL 2 の docker-desktop
ディストリビューションを経由 するように変更されます。
これにより、Docker Desktop を起動すると、docker images
の一覧が変わることがあります。
もし WSL 内の Docker 環境を変えたくない 場合は、次の方法を試してください。
wsl --set-version Ubuntu 1
にして、WSL 2 ではなく WSL 1 を使う(WSL 1 では Docker Desktop 連携がない)。WSL Integration
設定を無効化する。dockerd
を手動で起動し、独立した環境を維持する。sudo service docker start
で WSL 内で Docker デーモンを起動。context
を使い分ける
docker context
コマンドを使用し、Docker Desktop のデーモンと WSL 内のデーモンを使い分ける。Docker for Windows を起動すると、WSL で動作している Docker の デーモン・ネットワーク・ストレージ設定 などが変更され、docker images
の結果が変わる可能性がある。
WSL 内で独立した Docker 環境を維持したい場合は、Docker Desktop の WSL 統合を無効化するか、docker context
を適切に設定すると良い。
ただ、これだと、Docker for Windowsをアンインストールできないんだよなぁ。
さらに検討.....
結局のところ、WSLのDockerから、Docker for Windowsで作ったディレクトリから、docker-compose down して、docker-compose up -d して作り直すのが一番てっとり早かった、というオチでした(私の場合)。
WindowsにGnuplotをインストールする手順を以下に説明します。
gnuplot-x.x.x-win64.exe
)をダウンロードします。.exe
ファイルをダブルクリックして実行します。コマンドプロンプトやPowerShellで簡単にGnuplotを実行するには、PATH環境変数にGnuplotのインストールディレクトリを追加します。
Path
を選択し、「編集」をクリック。C:\Program Files\gnuplot\bin
)を追加。Win + R
を押して「cmd」と入力し、Enterキーを押します。gnuplot
gnuplot>
)が表示されるので、以下を入力してバージョンを確認します。show version
インストールが成功している場合、以下のコマンドで簡単なプロットが表示されます。
plot sin(x)
これでGnuplotのインストールは完了です。
以下の手順で Gnuplot スクリプトを保存し、73.csvを表示する方法を説明します(73.csvはファイルの一つにすぎません)
plot_73.gnu
など、わかりやすい名前で保存してください。# Gnuplot Script for 3D Plot# X, Y, Z 軸の範囲を設定
set xrange [130.3296537290101:130.56028128619576]
set yrange [33.49812295428995:33.67972606282988]
set zrange [0:1440]
# 軸ラベル
set xlabel "Longitude"
set ylabel "Latitude"
set zlabel "Time (Minutes)"# タイトル set title "3D Plot of GPS Data"
# CSVのヘッダー行をスキップする設定
set datafile separator "," # カンマ区切りを指定
set key autotitle columnhead # ヘッダーをタイトルに使用(必要に応じて)# データの3Dプロット
splot "73.csv" every ::1 using 9:8:($6*60+$7) with points pointtype 7 pointsize 1 lc rgb "blue" title "GPS Points"
plot_73.gnu
ファイルと 73.csv
ファイルを同じディレクトリに配置してください。
gnuplot>
) 上で以下のコマンドを実行します。
ターミナルから直接スクリプトを実行できるようにするには、以下のコマンドを使用します。
gnuplot plot_73.gnu
これにより、Gnuplot を起動せずにスクリプトを実行できます。
73.csv
) が正しいことを確認してください。73.csv
のパスをフルパスで指定することで、スクリプトと CSV が別のディレクトリにある場合でも動作します。例:
splot "/path/to/73.csv" every ::1 using 9:8:($6*60+$7) ...
$ go run . > NUL 2>NUL
でも"NUL"というファイルができてしまうました。
で、今、以下を試しています。
cmd ではなく PowerShell で実行する場合、$null を使用できます。
go run . *> $null
今で言う投稿サイトに"fj"というものがありました。
There was a posting site called “fj” back then.
かつて、そこでは、『「ナンバーディスプレイ通知」の是非』について、熱い議論が交されていました。
In the past, there were heated debates about the pros and cons of “number display notification.”
「ナンバーディスプレイ通知」とは、相手先の電話番号がスマホに表示されることです。
'Number display notification' is when the other party's phone number is displayed on your smartphone.
今となっては、『何のために、そんな議論をしていたんだろう』と思われるかもしれません。
Now, you may be thinking, 'What was the point of all that discussion?
ですので、当時のことを思い出しながら書いてみます。
So, I'll try to write about it while remembering what happened back then.
-----
(1)プライバシー保護: 発信者の番号通知がプライバシー侵害につながる可能性が懸念された。
(1) Privacy protection: There were concerns that caller ID could violate privacy.
(2)受信者の権利: 受信者の利便性と発信者の匿名性の対立が議論された。
(2) Recipient's rights: The conflict between the recipient's convenience and the sender's anonymity was discussed.
(3)迷惑電話対策: 迷惑電話抑止の利点と偽装番号などの新たな問題が指摘された。
(3) Measures against nuisance calls: The benefits of discouraging nuisance calls and new problems, such as spoofed numbers, were pointed out.
(4)法的・技術的課題: 技術や料金、法整備が利用者の選択肢に影響を与えるとされた。
(4) Legal and technical issues: Technology, fees, and legal developments are said to affect users' choices.
(5)社会的影響: ナンバーディスプレイ普及によるコミュニケーションの変化が懸念された。
(5) Social impact: There were concerns about changes in communication due to the spread of number display.
-----
今となっては、「相手先の電話番号が表示されない」ということ自体、意味が分からないと思うのですが、当時は、『発信者のプライバシーを保護する』という、考え方があったのです。
Nowadays, I find it incomprehensible that the other party's phone number is not displayed, but at the time, there was a concept of 'protecting the privacy of the caller.'
この議論は、「ナンバーディスプレイ通知サービス = 是」とする側が優位だったように記憶しております。
I remember that the side that said “Number Display Notification Service = Good” was in the majority.
理屈はシンプルでして「ナンバーディスプレイ通知 = 非」とする人は、ナンバーディスプレイ通知サービスを使わなければ、それで足るだろう、という理由でした。
The logic is simple: if you don't use the number display notification service, it should be sufficient to set “number display notification = bad.”
ただ、これを個人の自由選択の問題に矮小化してしまえば、『発信者のプライバシーを保護する』という考え方そもののが消滅することが公共の利益に反する、という主張もあり、私は、それはそれで一理あったと思います。
However, suppose this is reduced to personal freedom of choice. In that case, there is also the argument that the idea of 'protecting the privacy of the sender' itself will disappear, which is contrary to the public interest, and I think that has a point.
この問題は「SNSの匿名性」の問題と形を変えて、引き継がれているように思います。
This problem has been passed on differently as the “anonymity of SNS” problem.
今は、(1)完全キャッシュレス決済、(2)現金決済との併存、という意見の論争があるようです。
There seems to be a debate between the opinions of (1) utterly cashless payment and (2) coexistence with cash payment.
これについては、調べて頂ければ、双方、説得力のある論が展開されていますので、興味のある人は調べて下さい。
If you investigate this, you will find that both sides have developed persuasive arguments. Please do so if you are interested.
-----
私が思い出すのは「地上デジタル放送」への切替の時の話です。
I remember the story of the switch to terrestrial digital broadcasting.
政府は10年も前から、切替を宣言していました(地上デジタル放送への完全移行を2011年7月24日に実施しましたが、この切替計画については約10年前の 2001年 から公知し、その10年間を移行期間としていました)。
The government had been announcing the switchover for 10 years (the complete switchover to terrestrial digital broadcasting was carried out on July 24th, 2011, but the switchover plan had been publicized about 10 years ago in 2001, and the 10 years was set aside as a transition period).
で、いざ「地上デジタル放送」への切替を行う1月前くらいから、マスコミは「高齢者や貧困者」を盾にした「地上デジタル放送反対キャンペーン」を実施はじめました。
So, about a month before the switch to terrestrial digital broadcasting, the media began to run a campaign against terrestrial digital broadcasting, using older people and people with low incomes as a shield.
当然、政府はそれに応じませんでした。
Naturally, the government did not respond.
さすがに、この件に関しては、私は『政府は悪くない』と思いましたよ。
As expected, I thought the government was not to blame.
だって、10年間も移行期間があったんですよ。こればかりは『いざとなったらゴネればなんとかなる』は、通用しないと思いました。
After all, there was a 10-year transition period. In this case, the saying “if push comes to shove, you can make do by complaining” wouldn't work.
私が覚えている限り、この騒ぎは、切替から1~2週間後にはニュースにも出てこなくなりました。
As far as I can remember, this commotion stopped appearing in the news after the switchover, which took place a week or two ago.
大した手間ではなかったからでしょう(あるいは、テレビがなくても何とかなることが、分かったのかもしれません)。
It probably wasn't much trouble (or maybe they realized they could manage without a TV).
-----
今年は「マイナンバーカード」で、一悶着おきそうな感じがしますが、多分、これも「地上デジタル放送」と同じような結末になるだろうと予想しています。
This year, there has been much fuss about the My Number Card, but I think it will probably be like terrestrial digital broadcasting.
以下は現在TCをインストールして設定したラズパイのifconfigです。
pi@raspberrypi:~$ ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.88 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::ba27:ebff:fe69:5b65 prefixlen 64 scopeid 0x20<link>
inet6 240f:30:a9ce:1:ba27:ebff:fe69:5b65 prefixlen 64 scopeid 0x0<global>
ether b8:27:eb:69:5b:65 txqueuelen 1000 (Ethernet)
RX packets 10040 bytes 750155 (732.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1326 bytes 166549 (162.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:69:5b:65 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether f4:4d:ad:04:49:d5 txqueuelen 1000 (Ethernet)
RX packets 11626 bytes 1414469 (1.3 MiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 1326 bytes 166549 (162.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 6 bytes 234 (234.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6 bytes 234 (234.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::ba27:ebff:fe3c:e30 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:3c:0e:30 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23 bytes 3164 (3.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0eth0 → eth1 の方向に bitrateを500
eht1 → eth0の方向にbitrateを300
で設定したい時、入力するコマンドを、 既存の設定をクリアにするところから教えて下さい
以下の手順で、既存の設定をクリアし、eth0
からeth1
の方向にビットレート500kbps、eth1
からeth0
の方向にビットレート300kbpsを設定できます。
tc
設定をクリアするまず、eth0
とeth1
のtc
設定を削除します。
eth0 → eth1
のビットレートを500kbpsに制限するeth0
にtc
を設定します。
eth1 → eth0
のビットレートを300kbpsに制限するeth1
にtc
を設定します。
以下のコマンドで設定を確認できます。
例えば、遅延やパケットロスを追加したい場合は、以下のように設定します。
eth0 → eth1
に遅延を追加(例: 50ms)eth1 → eth0
にパケットロスを追加(例: 10%)この設定により、双方向の帯域制御が行われます。必要に応じて、burst
やlatency
のオプションを追加してください。