未分類

まだ問題山積だけど、golangのCSVパースが通った。

package main

import (
	"encoding/csv"
	"encoding/json"
	"fmt"
	"strings"
)

type Location struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

type Record struct {
	ID         int        `json:"id"`
	UserID     int        `json:"user_id"`
	Distance   float64    `json:"distance"`
	Place      []Location `json:"place"`
	Speed      []float64  `json:"speed"`
	Prediction int        `json:"prediction_type"`
	StartAt    string     `json:"start_at"`
	EndAt      string     `json:"end_at"`
}

func main() {
	// 提供されたCSVデータ
	csvData := `50,7,53.04935656638487,"[{""lat"": 34.6653, ""lng"": 135.2241}, {""lat"": 34.6653, ""lng"": 135.2241}, {""lat"": 34.6652, ""lng"": 135.2241}, {""lat"": 34.6652, ""lng"": 135.224}, {""lat"": 34.6651, ""lng"": 135.224}, {""lat"": 34.665, ""lng"": 135.224}, {""lat"": 34.6649, ""lng"": 135.2239}]","[0.0, 0.0001, 0.0002, 0.0002, 0.0004, 0.0004, 0.0004]",1,2023-03-03 07:40:00,2023-03-03 07:43:00`

	// CSVデータを読み込む
	r := csv.NewReader(strings.NewReader(csvData))
	record, err := r.Read()
	if err != nil {
		fmt.Println("CSVデータを読み込めません:", err)
		return
	}

	// CSVデータをパース
	id := record[0]
	userID := record[1]
	distance := record[2]
	placeJSON := record[3]
	speedJSON := record[4]
	prediction := record[5]
	startAt := record[6]
	endAt := record[7]

	// JSONデータをパース
	var place []Location
	if err := json.Unmarshal([]byte(placeJSON), &place); err != nil {
		fmt.Println("Placeデータをパースできません:", err)
		return
	}

	var speed []float64
	if err := json.Unmarshal([]byte(speedJSON), &speed); err != nil {
		fmt.Println("Speedデータをパースできません:", err)
		return
	}

	// パースしたデータを表示
	fmt.Println("ID:", id)
	fmt.Println("User ID:", userID)
	fmt.Println("Distance:", distance)
	fmt.Println("Place:", place)

	// Placeを要素単位で表示
	fmt.Println("Place:")
	for _, loc := range place {
		fmt.Printf("Lat: %.4f, Lng: %.4f\n", loc.Lat, loc.Lng)
	}

	fmt.Println("Speed:", speed)

	// Speedを要素単位で表示
	fmt.Println("\nSpeed:")
	for i, s := range speed {
		fmt.Printf("Index %d: %.4f\n", i, s)
	}

	fmt.Println("Prediction Type:", prediction)
	fmt.Println("Start At:", startAt)
	fmt.Println("End At:", endAt)
}


 

出力結果

ID: 50
User ID: 7
Distance: 53.04935656638487
Place: [{34.6653 135.2241} {34.6653 135.2241} {34.6652 135.2241} {34.6652 135.224} {34.6651 135.224} {34.665 135.224} {34.6649 135.2239}]
Place:
Lat: 34.6653, Lng: 135.2241
Lat: 34.6653, Lng: 135.2241
Lat: 34.6652, Lng: 135.2241
Lat: 34.6652, Lng: 135.2240
Lat: 34.6651, Lng: 135.2240
Lat: 34.6650, Lng: 135.2240
Lat: 34.6649, Lng: 135.2239
Speed: [0 0.0001 0.0002 0.0002 0.0004 0.0004 0.0004]

Speed:
Index 0: 0.0000
Index 1: 0.0001
Index 2: 0.0002
Index 3: 0.0002
Index 4: 0.0004
Index 5: 0.0004
Index 6: 0.0004
Prediction Type: 1
Start At: 2023-03-03 07:40:00
End At: 2023-03-03 07:43:00

2023,江端さんの忘備録

多くの飲食店で、テーブルに備えつけられたタブレットからメニューをオーダーするシステムが、導入されています。

Many restaurants have installed systems allowing customers to order tablet menu items at each table.

今や、そういうシステムがない店舗の方が珍しいくらいです。

Nowadays, finding a restaurant without such a system is so rare.

最低賃金が上がり、人不足が深刻な中、これは当然の流れと言えます。

This is a natural trend, with minimum wages rising and a severe labor shortage.

ただ、言うまでもないのですが、これらのタブレットのインターフェースは、『絶望的なまでに使いにくい』。

But needless to say, the interface of these tablets is 'hopelessly difficult to use.

『このタブレットのインターフェースを設計しているヤツは、バカなのか』と思います ―― かなり本気で。

I think, 'Are the people designing this tablet interface stupid?' -- quite seriously.

しかし、面倒なので、このインターフェースについての批判は割愛します。

However, since it is tedious, I will omit the criticism of this interface.

-----

万人に共通に使いやすい注文システムの究極は ―― 『タブレットを使わない、口頭でのオーダー』、つまり従来通りです。

The ultimate ordering system that is easy for everyone is -- "no tablets, verbal orders," in other words, the same as before.

ですので、現在のタブレット注文システムが、「音声入力」と「生成AI」からなる、音声による自動オーダシステムになっていくことは、ほぼ確実です。

Therefore, it is almost certain that the current tablet ordering system will be replaced by an automated voice-based ordering system consisting of "voice input" and "generated AI.

近い未来、『音声入力生成AIと客が、オーダーの違いで、口論になる』という場面を見られるようになるでしょう。

We will soon see voice input generation AI and customers arguing over different orders.

そして、100%完全録音された会話によって、多くの場合、『客の過失(オーダーのミス)が、簡単に確認される』ということになるでしょう。

And, in many cases, a 100% fully recorded conversation will 'easily confirm the customer's negligence (mistake in ordering).

-----

気になるのは、その開始時期です。

What is of interest is the timing of its service-in.

私は、年内に登場、来年はトライアル期間、再来年あたりには飲食業界では普通になる、という気がしています。

They will appear by the end of the year; next year will be a trial period, and around the year after that, they will become the norm in the food and beverage industry.

『お客様は神様です』の旧態依然の価値観で生きているジジイたちに告ぐ。

2011,江端さんの忘備録

家族が実家に帰省しているので、当分の間、私が掃除・炊事・洗濯を担当することになります。

料理を作ることは、得意ではありませんが、苦でもありません。

料理を、一種の「システム構築と検証」と考えれば、それなりに楽しい。

最近、「コーラだけを使ったカレー」の実験で酷い目に会いましたが、通常の料理では、このような無謀は挑戦はしませんので、大きな失敗もありません。

-----

先日、本屋で「男子食堂」という雑誌を購入しました。

この雑誌のコンセプトなのか、今月号の特集なのかは忘れましたが、内容は、

「電子レンジだけで作る料理」

です。

『ほぉ、そりゃ楽で良いな』と思い購入しましたが、雑誌の中身を見てビックリしました。

肉じゃが、鶏のから揚げ、煮豚、麻婆豆腐、サバの味噌煮、ハンバーグ、カレーライス、スペアリブ、天麩羅から、プリン、ケーキに至るまで、ざっと数十メニュー全部が、全て、

「電子レンジだけで作れる」

-----

これだ。これで良い。

■独身者だけでなく、小学生から高齢者に至るまで、「火気」を一切使わず、最悪のケースでも、食材がレンジの中で破裂する程度の、絶対安全料理方法。

■調理器具と食器が完全一体化し、必要な人数分だけを正確に調理し、加熱調理用の油が一切不要の健康低カロリー料理

■必要な処理は、食材を切り、耐熱ボール(あるいはドンブリ)に放り込み、レンジのスイッチを回す程度。

「体に悪い」と非難を浴びつつ、それでも便利な食材として使われてきた、カップラーメンの時代は、今、終焉を迎えた。

もはや、ガスレンジは勿論、プライパンでさえ、過去の遺物とされるる時代が到来したのである。

-----

非結婚社会、高齢化社会、夫婦共稼ぎ社会、少子化社会、これらの問題に対応する現実的な解として、私はここに、

「電子レンジ調理過程」プログラムの必修化を提言します。

2023,江端さんの忘備録

「毎日、料理を作るのが、こんなに大変とは思わなかった」

"I didn't realize how hard it would be to cook a meal daily."

と久々に実家に帰ってきている長女がこぼしています。

My eldest daughter has been home for a long time and is complaining.

実際、『そうだろうなぁ』と思います。

I think, 'I guess so.

私みたいに、思い出した時に、自分が食べたい料理を作るのとは訳が違います。

It differs from cooking a dish you want to eat when you remember it, like I do.

作ってもらった料理に文句を言う人は、『料理を作るタスクの交代を申し出ている』と解釈すべきです。

A person who complains about the food that has been prepared should be interpreted as 'offering to take over the task of preparing the food.

まあ、それはさておき。

Well, let's put that aside.

-----

長女:「もっと、基本的な料理の技術と、料理のバラエティを揃えておくべきだった」

Daughter: "I should have had more basic cooking skills and a better variety of dishes."

私:「いや、それは違うな。料理も含めて全てのタスクは、状況に応じたOJT(On the Job Training)で良いんだよ」

Me: "No, that's not true. All tasks, including cooking, can be done on-the-job training (OJT) depending on the situation."

長女:「でも、基礎力がないと、そこから上がることが難しいんだよ」

Daughter: "But I don't have the basic skills, so moving up from there is hard."

一見、ティーンエイジャの「受験」の話をしているようですが、語っている話題は「料理」です。

At first glance, it seems that we are talking about teenagers' "examinations," but the topic we are talking about is "cooking.

私:「うん、私も、学生のころ『塾』やら『家庭教師』やらのバイトなんぞばかりをやっていたことを、酷く後悔している」

Me: "Yes, I also regret that I had so many part-time jobs, such as "cram school" and "tutoring" when I was a college student.

長女:「?」

Daughter:"?"

私:「小さな定食屋やレストランで、フライパンや鍋を使わせてもらえるようなバイトを、もっと沢山すべきだった。"調理"に関する技術を、もっと学んでおくべきだったと思う」

Me: "I should have had many more part-time jobs in small set menus and restaurants where I was allowed to use pans and pots." I should have learned more about the art of "cooking."

一般的な家庭料理が作れるレベルになっておくことが、いかに重要なことだったか、私のその後の人生で思い知ることになります。

I would later realize how important it was to have a skill level in common home cooking.

『冷蔵庫の中に残っているショボイ食材だけで、一品を作れるかどうか』。男女関係なく、これは重要なことのように思えます。

'Can you make a dish with only the shabby ingredients left in the fridge? This seems to be important regardless of gender.

-----

もっとも、最近は、栄養バランスもよく、美味しく、簡単なパッケージ食(弁当、冷凍食品等)も沢山ありますので、これが、本当に重要なことなのかは、判断が難しいところです。

However, it isn't easy to judge whether this is important since many packaged meals (bento boxes, frozen foods, etc.) are available these days that are delicious and easy to prepare, with good nutritional balance.

ただ、はっきり言えることは、『パッケージ食は、コストが高い』です。

However, what is clear is that 'packaged meals are expensive.

今後の私のリタイアなどを鑑みても、我が家の今後の生活がラクになっていくことは、ありえない話です。

In light of my future retirement, etc., our family's life can't be easier.

『50円で一品作れるか?』という問いに対して、"Yes"と言い続けるための訓練と準備は、怠れないのです。

"Can you make one dish for 50 yen?". We must be trained and prepared to keep saying "Yes.

男子食堂

 

2023,江端さんの忘備録

暗号に関するミステリーというのは面白いです。

It is interesting to have a mystery about cryptography.

でも多くのミステリーは、「暗号」の意味を取り違えていると思います ―― もちろん、著者も読者も分かっていることではありますが。

But I think many mysteries misunderstand the meaning of "code" -- something both authors and readers know, of course.

暗号とは、

A cipher is a message that

(1)全世界に公開される方法でしか運ぶことができないメッセージ

(1) can only be carried in a way that is open to the entire world,

であるにも関わらず、

yet

(2)特定の人物にのみが復号できるメッセージ

(2) can only be decrypted by a specific person.

のことです。

上記(1)の公開メッセージ中に、(2)の復号のヒントが含まれていれば、その暗号はその目的を達成することはできません。

The cipher cannot achieve its purpose if the public message in (1) above contains the decryption hint in (2).

また、その人間の資質(能力)によってのみ解読できるものであるなら、それは特定の人物に向けたメッセージではないので、暗号とは言えません。

Also, if it can only be deciphered by the qualities (abilities) of the person, it is not a cipher because it is not a message to a specific person.

そして、それが誰にも復号できないのであれば、それは「暗号」ですらありません。ただの文字列です。

And if no one can decrypt it, it is not even a "cipher." It is just a string of characters.

つまり、厳密な意味では、小説やドラマや映画で登場する暗号は『暗号ではない』のです。

In other words, in a strict sense, the ciphers that appear in novels, dramas, and movies are not 'ciphers.

-----

YouTubeで、ドラマ「ミステリと言う勿れ」のダイジェストを見ています。

I am watching a digest of the drama "Not to Mention Mystery" on YouTube.

私は、『一緒にドラマ見ている人に、こういう話をするべきではない』し、ましてや、『RAS暗号の原理などを得意気に語るべきではない』ということだけは分かっています。

All I know is that 'I shouldn't talk about these things to people I'm watching drama with,' much less 'I shouldn't talk about the principles of the RAS cipher in a way that I'm good at.

―― ママ友は、暗号を使ってメール通信を行っている

2014,江端さんの忘備録

以前、ある人のブログで、いわゆる「ママ友」どうしのメールを読んだことがあります。

The other day, I read a so-called mail of "mother of my child friend" in a person's blog.

全然わからん。

I don't understand what she wants to say.

■一つのフレーズが非常に長い

- One phase is too long.

■そのフレーズ間の接続詞、「でもね」「だからね」が、そのフレーズの関連の役割を果たしていない。

- There are a lot of conjunctions in her mail, but the conjunction doesn't work well, for example "However" and "therefore"

■フレーズの語尾に、やたら「ごめんね」が多い。

- The words "Sorry" come at the end of the sentence.

総じて、「メールの趣旨が読みとれない」。

Generally speaking, I cannot understand the contents of the mail.

------

ところが、嫁さんは、そのメールを読むと、その趣旨を一読で理解して、的確にその要旨を解説してくれました。

However, as soon as my wife read the mail, she could understand and teach me the content.

私、そのとき、わかったのです。

At that time, I could find a fact.

―― ママ友は、暗号を使ってメール通信を行っている

"Mother of my child friend" uses cryptographs in her mail."

のだと。

そのメールは、その環境を理解できるものだけがもつ公開鍵で、その内容を理解することができるのだ、と。

The mail will be decoded and understood by an open key so that the particular persons can understand the background of each other.

-----

我々(特に理系頭脳の、さらには男性)は、このようなメールを、「意味がわからない」「論理破綻している」などと言ってきました。

We, especially men in the science and engineering majors, keep saying that these emails are "incomprehensible" or "unintelligible."

とんでもない誤解でした。

This is a ridiculous misunderstanding.

なんのことはない。

Nothing special.

私たちに、暗号解読のデコーダーがなかっただけだったのことだったのです。

We don't have a decode key to resolve the cryptograph mail.

批判されるべきは、ママ友が有する高度な情報解析能力機能を有しない、

―― 私たち理系男だったのです。

Men in the science and engineering majors who do not have the ability for high information analysis function of the mothers should be criticized.

2023,江端さんの技術メモ

UbuntuでFTPサーバを停止するには、サーバソフトウェアによって異なります。一般的に、Ubuntuでよく使われるFTPサーバソフトウェアはvsftpd(Very Secure FTP Daemon)です。以下に、vsftpdを停止する方法を説明します。もし他のFTPサーバーソフトウェアを使用している場合は、それに対応した手順を適用してください。

vsftpdを停止する手順:

  1. ターミナルを開きます。
  2. vsftpdサービスを停止します。次のコマンドを使用します:
    sudo systemctl stop vsftpd
  3. vsftpdサービスが停止したことを確認するために、次のコマンドを使用してサービスのステータスを確認します:
    sudo systemctl status vsftpd

    ステータスが「inactive」(非アクティブ)になっているはずです。

  4. vsftpdサービスが自動起動しないように設定したい場合、次のコマンドを使用して自動起動を無効にします:
    sudo systemctl disable vsftpd

これにより、システムの再起動時にvsftpdサービスが起動しないようになります。

以上の手順に従うことで、vsftpd FTPサーバーを停止し、必要に応じて自動起動を無効にできます。

2023,江端さんの技術メモ

/etc/vsftpd.conf

listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
ascii_upload_enable=YES
ascii_download_enable=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
utf8_filesystem=YES

2023,江端さんの忘備録

大学の講義の内容が厳しい。

The content of the university lectures is challenging.

英語の本を読んで、英語プレゼン発表1時間って ―― そういうのは「英語に愛されているエンジニア」の領分だと思う。

Reading an English book and presenting an English presentation for an hour -- I think that kind of thing is the domain of "engineers who are loved by the English language.

でも、必須単位取れないと、卒業できないしなぁ。

But if I don't get the required credits, I won't be able to graduate.

というか、卒業したらどうだというんだ? 就職に有利てか? もうリタイア目の前なのに?

However, what do I think about graduating? What about the job opportunities? Even though I'm about to retire?

―― あ、これは考えたらダメなやつだ

"Oh, I'm losing this one if I think about it."

と思ったので、もう止めます。

So, I stop it.

-----

私:「あのさ、『コモンズの悲劇』って知っている?」

Me: "Have you ever heard of The Tragedy of the Commons?"

嫁さん:「知らない。『ドーハの悲劇』なら知っているけど」

Wife: "I don't know. I know about the Doha Tragedy, though."

まあ、そうだろうな、と思いました。

Well, I thought, I guess so.

ちなみに、私が『ドーハの悲劇』というフレーズを知ったのは、ごく最近です

Incidentally, it was only recently that I learned the phrase "Doha Tragedy."

江端:「分かるも何も、ゲーム理論で、コラムを書いているくらいなんだが ―― 知らなかったか?」