この記事、何?
表題の通り。10分で書いたような記事。
CSVファイルの1行目をとってsplit(',')して返す。それだけ。
伏線・・・かも?
コード
def get_lines_from_textfile(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
lines = f.readlines()
return lines
def get_columns_list(csvpath):
line_1st = get_lines_from_textfile(csvpath)[0]
return line_1st.split(',')
def main():
csvpath = 'solubility.test.csv'
columns = get_columns_list(csvpath)
for column in columns:
print(column)
if __name__ == '__main__':
main()
感想
特になし。