0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pythonでcsvファイルを読み込み表示させる

Posted at

シンプルですが,単に,csvファイルを読み込み表示させるpythonプログラムです.

import pandas as pd
#import matplotlib.pyplot as plt #もちろん,これはなくてもいいですね...
#import numpy as np #もちろん,これもなくてもいいですね...
import csv


inp_file="C:\\Users\\name\Desktop\\nmea20210705\\2021-07-05_09_GNRMC.csv"
#ファイルがUTF-8なら
enc_sty="UTF-8"
#ファイルがshift_jisなら
# enc_sty="shift_jis"

with open(inp_file, "r", encoding=enc_sty, errors="", newline="" ) as f:
    lst = csv.reader(f, delimiter=",")
    # df = pd.DataFrame(lst).rename(columns={0:'ID',1:'time',2:'de',3:'lat',5:'lon',7:'knot',9:'date',12:'mode'})
    df = pd.DataFrame(lst)

# 読み込んだファイルを表示する
df

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?