0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【基礎から】PythonでExcel扱えるようにする(4)テキストデータの読み込み

Posted at

目的

テキストファイルから定型部分の取り込みをできるようにする。

step5:テキストファイルの読み込み

def step05():
    print("step05")

    # テキストファイルオープン
    with open('./lifedata_man_2023.txt', encoding='utf-8') as f:
        # 1行読み込み(先頭行)
        line = f.readline()
        while line:
            # 1行のデータを表示(改行部分を除く)
            print(line.rstrip("\n"))
            # 次の行を読み込み
            line = f.readline()   

# 動作部 
step05()

動作結果(terminal)

image.png

本編へ戻る

履歴

2024/08/10 新規作成

リンク

[1] 生命表 2023年 男
https://www.mhlw.go.jp/toukei/saikin/hw/life/life23/dl/life23-06.pdf

eof

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?