Created
July 19, 2016 08:28
-
-
Save kurozumi/6b29cfe3c8ba9436640b49c756962900 to your computer and use it in GitHub Desktop.
【Python】様々な種類のファイルを読み込めるファイルリーダークラス
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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