forked from buriburisuri/timeseries_gan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
executable file
·39 lines (39 loc) · 1019 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import wget
import zipfile
import pandas as pd
import os
import shutil
import sys
from pdb import set_trace as bp
#
def dclean(dfiles):
if os.path.exists('asset'):
shutil.rmtree('asset')
for i, ival in enumerate(dfiles):
try:
os.remove(ival)
except OSError:
pass
return
#
zipfilename = 'occupancy_data.zip'
dfiles = ['datatest2.txt', 'datatest.txt', 'datatraining.txt']
dfiles.append(zipfilename)
dclean(dfiles)
if len(sys.argv) > 1:
if sys.argv[1] == 'clean':
sys.exit()
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/00357/'+zipfilename
filename = wget.download(url)
zip_ref = zipfile.ZipFile(filename, 'r')
zip_ref.extractall('./')
zip_ref.close()
df = pd.read_csv('datatraining.txt')
directory = 'asset/data'
if not os.path.exists(directory):
os.makedirs(directory)
df['time'] = df.index
df[['time','Temperature','Humidity']].to_csv(directory+'/sample.csv', index=False)
import train
dclean(dfiles)