compara-deep-learning/req_data.py

27 lines
550 B
Python
Raw Normal View History

2019-05-10 10:21:21 -07:00
import os
import pandas
import sys
import urllib.request as urllib
import pandas as pd
lf=[]
2019-05-11 11:22:42 -07:00
def download_data(x,dir_name):
fname=x.split("/")[-1]
path=os.path.join(dir_name,fname)
urllib.urlretrieve(x,path)
2019-05-10 10:21:21 -07:00
2019-05-11 11:22:42 -07:00
def get_data_file(file,dir):
2019-05-10 10:21:21 -07:00
if not os.path.isfile(file):
print("The specified file does not exist!!!")
sys.exit(1)
with open(file,"r")as f:
lf=f.read().splitlines()
2019-05-11 11:22:42 -07:00
if not os.path.exists(dir):
os.mkdir(dir)
2019-05-10 10:21:21 -07:00
for x in lf:
2019-05-11 11:22:42 -07:00
download_data(x,dir)