Skip to content

Commit

Permalink
fix IRS URLs script
Browse files Browse the repository at this point in the history
  • Loading branch information
kelle committed Sep 26, 2023
1 parent ab9e2aa commit 442328b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/updates/fix_IRS_spectra_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from scripts.ingests.utils import load_simpledb
from astropy.table import Table


SAVE_DB = True # save the data files in addition to modifying the .db file
RECREATE_DB = True # recreates the .db file from the data files

# LOAD THE DATABASE
db = load_simpledb('SIMPLE.db', recreatedb=RECREATE_DB)


# link to live google sheet
link = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQG5cGkI2aHPHD4b6ZZPTU4jjQMirU_z-yhl5ElI3p6nCIufIL64crC-yFalF58OauWHxmYvEKR_isY/pub?gid=0&single=true&output=csv'
columns = ['source', 'original_spectrum', 'fixed_spectrum']
spectra_link_table = Table.read(link, format='ascii', data_start=2, names=columns, guess=False, fast_reader=False, delimiter=',')

for row in spectra_link_table:
# t = db.query(db.Spectra).filter(db.Spectra.c.original_spectrum == row['original_spectrum']).astropy()
# print(t['spectrum'])
with db.engine.connect() as conn:
conn.execute(db.Spectra.update().where(db.Spectra.c.original_spectrum == row['original_spectrum']).values(spectrum=row['fixed_spectrum']))
conn.commit()

# WRITE THE JSON FILES
if SAVE_DB:
db.save_database(directory='data/')

0 comments on commit 442328b

Please sign in to comment.