I want SIMBAD to treat the dash(hyphen) as a space

46 Views Asked by At

I have a code using astroquery.Simbad to query star names. However Simbad working with names like "LP 944-20". However, the data contains names as "LP-944-20". How can i make code to ignore that first dash(hyphen)?

My code:

from astroquery.simbad import Simbad
result_table = Simbad.query_object("LP-944-20", wildcard=True)
print(result_table)
1

There are 1 best solutions below

0
On

One simple approach would be to just replace the first hyphen with space:

inp = ["LP-944-20", "944-20", "20"]
output = [x.replace("-", " ", 1) for x in inp]
print(output)  # ['LP 944-20', '944 20', '20']