Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Data-Analytics
Datasets
Commits
b5afcb7d
Commit
b5afcb7d
authored
Jul 19, 2018
by
Agnes Ansari
Browse files
Upload New File
parent
6a16c2f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
download_data.py
0 → 100644
View file @
b5afcb7d
# Author: Alexandre Boucaud <aboucaud@lal.in2p3.fr>
# License: BSD 3 clause
from
__future__
import
print_function
import
os
import
sys
try
:
from
urllib.request
import
urlretrieve
except
ImportError
:
from
urllib
import
urlretrieve
URLBASE
=
'https://storage.ramp.studio/astrophd_tutorial/{}'
DATA
=
[
'data_prace_train.npy'
,
'data_prace_test.npy'
,
'labels_prace_train.npy'
,
'labels_prace_test.npy'
]
def
main
(
path
=
None
,
output_dir
=
'data'
):
path
=
path
or
""
fullpath
=
os
.
path
.
join
(
path
,
output_dir
)
filenames
=
DATA
urls
=
[
URLBASE
.
format
(
filename
)
for
filename
in
filenames
]
if
not
os
.
path
.
exists
(
fullpath
):
os
.
mkdir
(
fullpath
)
for
url
,
filename
in
zip
(
urls
,
filenames
):
output_file
=
os
.
path
.
join
(
fullpath
,
filename
.
replace
(
'_prace'
,
''
))
if
os
.
path
.
exists
(
output_file
):
print
(
"{} already downloaded"
.
format
(
filename
))
continue
print
(
"Downloading from {} ..."
.
format
(
url
))
urlretrieve
(
url
,
filename
=
output_file
)
print
(
"=> File saved as {}"
.
format
(
output_file
))
if
__name__
==
'__main__'
:
try
:
path
=
sys
.
argv
[
1
]
main
(
path
=
path
)
except
IndexError
:
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment