Created
August 5, 2015 01:48
-
-
Save m-note/dfb8145f8a3f6868009f to your computer and use it in GitHub Desktop.
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
def resultsSave(ext_df, path="/Users/S/Desktop/", name="diet",type="csv"): | |
# 2種類の形式での保存を可能にする | |
if type=="csv": | |
save_path = os.path.join(path, (name + ".csv")) | |
ext_df.to_csv(save_path) # Excelでは開くと文字化けしたが、Google Spreadsheetで見る限り問題なし | |
elif type=="pandas": | |
save_path = os.path.join(path, (name + ".pkl")) | |
ext_df.to_pickle(save_path) | |
else: | |
print("File type you specified is not defined") | |
def resultsOpen(readpath): | |
# ファイルの形式に合わせて、異なる方法で開く | |
root, ext = os.path.splitext(readpath) | |
if ext == ".csv": | |
df = pd.read_csv(readpath) | |
elif ext == ".pkl": | |
df = pd.read_pickle(readpath) | |
else: | |
print("This file is not supported.") | |
return df | |
#resultsOpen(save_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment