Skip to content

Instantly share code, notes, and snippets.

@ryosan-470
Created April 18, 2014 04:37
Show Gist options
  • Save ryosan-470/11025010 to your computer and use it in GitHub Desktop.
Save ryosan-470/11025010 to your computer and use it in GitHub Desktop.
coins13向け上限解除申請可否診断スクリプト

coins13向け上限解除申請可否診断スクリプト

Requirements

  • Python 3.x (Testing on Python 3.2 or higher)
  • score csv file from TWINS (Download its file before running this script)

WARNING

このスクリプト自体自分向けに作ったのでけっこう適当です.しかもPython初心者のためソースコードがゴミですがご容赦ください.更に正しくない結果を吐き出す可能性がありますが私は責任を負いませんので御注意ください.

判定ルール

単純にAとA+の科目更にPとなっている科目をすべてA扱いとして数えています

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import csv
import sys
# 登録の判定を行う
# A,A+の取得単位割合を返す
def getrate(csvfile):
total_score = 0
great_score = 0
for row in csv.reader(csvfile):
try:
total_score += float(row[5])
except ValueError:
total_score += 0
if "A" in row[6] or "A+" in row[6] or "P" in row[6]:
great_score += float(row[5])
return total_score, great_score, great_score / total_score * 100
def main():
args = sys.argv # コマンドライン引数のリストを取得
if len(args) != 2:
print("Usage: python3 calchiger.py hoge.csv")
quit()
csvfile = open(args[1], "r", encoding="UTF-8")
result = getrate(csvfile)
print("上限解除申請可否診断スクリプト for coins13")
print("総取得単位数は"+str(result[0])+"単位")
print("A,A+の単位数は"+str(result[1])+"単位")
print("割合は"+str(int(result[2]))+"%")
if result[2] >= 60:
print("45単位を超えた履修が可能です")
else:
print("45単位を超えた履修は許可されていません")
csvfile.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment