In the spectrum of the Sun, for example, our spectrographs (the instruments we use to study the spectrum) can resolve more than 15,000 lines just in the range that our eyes can see. If we look at the entire electromagnetic range, the Sun has at least three times as many lines, and perhaps even more. We can identify many of them, but at least a few thousand remain unknown today. Many of the unidentified ones lie at ultraviolet wavelengths (shorter than what our eyes can see); these lines blend together, making it hard to distinguish one from the next, even with our best instruments.
The study of spectral lines is really just the study of the complex configurations and behaviors of electrons in atoms. As astronomers, we owe a large part of our success in identifying spectral lines in astronomical objects to laboratory spectroscopists. These scientists dedicate years, and sometimes entire careers, to studying the detailed spectroscopic signatures of atoms, molecules, and plasmas (hot ionized gases) in laboratories on Earth.
Thanks to this help on the ground, astronomers have been able to successfully identify tens of thousands of lines in all sorts of objects in space: stars, galaxies, nebulae, quasars, supernovae, comets, atmospheres of planets, and even the gas and dust between them all.