時間割作成問題作成中に知ったのですが、Pulpでは、pandasで簡単にネット上のCSVファイルが読めます。
lesson_df = pd.read_csv("https://raw.githubusercontent.com/ryosuke0010/opt_test/master/composition.csv")
スケジュールナース上のPythonは、pandas等の大きなライブラリは搭載していないので、上記ソースでネット上のCSVファイルを読むことは出来ません。 そこで、pandasなしに次のようにして読んでいます。
def get_list_of_rows():
    url="https://raw.githubusercontent.com/ryosuke0010/opt_test/master/composition.csv"
    response = urllib.request.urlopen(url)
    lines = [l.decode('utf-8') for l in response.readlines()]
    #print(lines)
    reader=csv.reader(lines)
    list_of_rows=list(reader)
    return list_of_rows
 
0 件のコメント:
コメントを投稿