Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【Python】様々な種類のファイルを読み込めるファイルリーダークラス
class FileReader(object):
@staticmethod
def yaml(file):
import yaml
with open(file, "r") as f:
return yaml.load(f)
@staticmethod
def csv(file):
import csv
with open(file, "r") as f:
return csv.reader(f):
@staticmethod
def json(file):
import json
with open(file, "r") as f:
return json.load(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.