Created
May 8, 2013 11:40
-
-
Save ferayebend/5539913 to your computer and use it in GitHub Desktop.
downloads SDSS spectrum of a given sql query result which includes specobjid
This file contains hidden or 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
#!/usr/bin/python | |
from os import popen | |
def loadData(inputFile,delimiter): | |
data = [] | |
for line in inputFile: | |
if line.startswith("#"): | |
continue | |
data.append([str(v) for v in line.strip().split(delimiter)]) | |
return data | |
def transpose(data): | |
return [[data[j][i] for j in range(len(data))] for i in range(len(data[0]))] | |
if __name__ == '__main__': | |
sql = 'result.csv' | |
data = loadData(open(sql),',') | |
cols = transpose(data[1:]) | |
print data[0] | |
i_id = data[0].index('specobjid') | |
print i_id | |
sdss_core = 'http://skyserver.sdss3.org/dr9/en/get/specById.asp?id=' | |
for id in cols[i_id]: | |
popen('wget '+sdss_core + id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment