LoginSignup
0
0

More than 1 year has passed since last update.

ポケモンのサイズ・体重をまとめたCSVを作りました

Posted at

ポケモンのサイズ・体重をまとめたCSVデータを作りました

https://github.com/kurogee/pokemon_detail
↑github初心者なので使い方間違ってたら教えてください...

・日本語名にのみ対応しています
・名前は「name」列
 サイズ(単位:m)は「size」列
 重さ(単位:kg)は「weight」列にあります
・エンコーディングはUTF-8です
・サイズは約27.4KBです

使い方の例(Python)

example.py
import pandas
from sys import exit

data = pandas.read_csv("pokemon_detail.csv", encoding="utf-8")
sizes = data["size"]
weights = data["weight"]
names = data["name"]

search_size = float(input("サイズ(m): "))
search_weight = float(input("体重(kg): "))
tolerance_size = float(input("サイズの許容範囲 (数値入力): "))
tolerance_weight = float(input("体重の許容範囲 (数値入力): "))

kouho = []
for size, name in zip(sizes, names):
    if search_size - tolerance_size <= float(size) <= search_size + tolerance_size:
        kouho.append(name)

if kouho == []:
    print("候補: なし")
    exit(0)
else:
    result = []
    for i in kouho:
        memory = list(names).index(i)
        if search_weight - tolerance_weight <= float(list(weights)[memory]) <= search_weight + tolerance_weight:
            result.append("名前: {}\n高さ: {} 重さ: {}".format(list(names)[memory], list(sizes)[memory], list(weights)[memory]))
    if result == []:
        print("候補: なし")
    else:
        print("+++検索結果+++")
        print("\n\n".join(result))
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0