# py -m pip install pandas
import pandas as pd
import json
df = pd.read_csv('./kifuwarabe-result.csv')
def main():
print("hello.world")
print(df)
print("hello.world2")
buf = '{"gameResult":[\n'
# len(df)
for i in range(0, len(df)):
buf = round(buf, i)
# 末尾のカンマを外す
if buf.endswith(','):
buf = buf[:-1]
buf += "]}"
print(buf)
print("hello.world3")
data = json.loads(buf)
with open('kifuwarabe-result.json', 'w') as writer:
a = json.dumps(data, indent=2)
print(a)
writer.write(a)
def round(buf:str, row:int):
return f"""{buf}
{{
"round":"{df.iloc[row]["round"]}",
"name":"{df.iloc[row]["name"]}",
"result1":"{df.iloc[row]["result1"]}",
"result2":"{df.iloc[row]["result2"]}",
"link1":"{df.iloc[row]["link1"]}",
"link2":"{df.iloc[row]["link2"]}"
}},"""
main()
Crieitは個人で開発中です。
興味がある方は是非記事の投稿をお願いします! どんな軽い内容でも嬉しいです。
なぜCrieitを作ろうと思ったか
また、「こんな記事が読みたいけど見つからない!」という方は是非記事投稿リクエストボードへ!
こじんまりと作業ログやメモ、進捗を書き残しておきたい方はボード機能をご利用ください!