Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created July 19, 2016 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/6b29cfe3c8ba9436640b49c756962900 to your computer and use it in GitHub Desktop.
Save kurozumi/6b29cfe3c8ba9436640b49c756962900 to your computer and use it in GitHub Desktop.
【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