Skip to content

Instantly share code, notes, and snippets.

@L3onSW
Last active February 26, 2024 03:18
Show Gist options
  • Save L3onSW/5092c49c4fb417237377e929447c2e99 to your computer and use it in GitHub Desktop.
Save L3onSW/5092c49c4fb417237377e929447c2e99 to your computer and use it in GitHub Desktop.

matlotlibでcsvファイルを表示する方法

以下のようにすると、ウィンドウが開きcsvファイルの中身を表示できる。

import matplotlib.pyplot as plt
import csv

csv_file = "example.csv"

with open(csv_file) as f:
    reader = csv.reader(f)
    contens_of_csv = [row for row in reader]

fig, ax = plt.subplots(1, 1)
data = contens_of_csv[1:]
column_labels = contens_of_csv[0]
ax.axis("tight")
ax.axis("off")
ax.table(cellText=data, colLabels=column_labels, loc="center")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment