aboutsummaryrefslogtreecommitdiffstats
path: root/python/download_daily.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/download_daily.py')
-rw-r--r--python/download_daily.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/python/download_daily.py b/python/download_daily.py
index 6fc14820..e69abfef 100644
--- a/python/download_daily.py
+++ b/python/download_daily.py
@@ -24,9 +24,6 @@ files = ftp.nlst()
workdate = str(datetime.today().date())
globeopdate = datetime.strftime(datetime.today(), '%Y%m%d')
-if not os.path.exists(os.path.join(root, workdate, "Reports")):
- os.makedirs(os.path.join(root, workdate, "Reports"))
-
pnlfiles = [filename for filename in files if "csv" in filename and \
globeopdate in filename and \
"Profit" in filename]
@@ -36,6 +33,10 @@ valuationfiles = [filename for filename in files if "csv" in filename and \
pnlfile = sorted(pnlfiles, reverse=True)[0]
valuationfile = sorted(valuationfiles, reverse=True)[0]
+if pnlfile:
+ if not os.path.exists(os.path.join(root, workdate, "Reports")):
+ os.makedirs(os.path.join(root, workdate, "Reports"))
+
for filename in [pnlfile, valuationfile]:
with open(os.path.join(root, workdate, "Reports", filename), "wb") as fh:
ftp.retrbinary('RETR ' + filename, fh.write)