astropy / astropy/astroquery

newlines in download_hitran Windows

Open
#1,189 0 comments 0 reactions 0 assignees View on GitHub
hitran
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

Hello,

I'm having trouble running the following codes on Windows:

```
from astroquery.hitran import read_hitran_file, cache_location, download_hitran
download_hitran(2, 1, 2000, 2300)
tbl = read_hitran_file(join(cache_location, 'CO2.data'))
```

crashes with
```
ValueError: invalid literal for int() with base 10: '\n'
```

The **line return character** is somehow handled wrongly by `download_hitran` and as a result, one every other line in the `CO2.data` module is empty. Typical output:

```
21 2271.501853 3.151E-29 3.941e+00.06800.083 4704.20210.76-.002928 1 4 4 11 1 4 4 01 Q 38e 3677642029 5 4 5 7 77.0 77.0

21 2271.507618 5.902E-30 1.687e+00.07730.104 4673.29590.69-.002458 3 1 1 13 3 1 1 03 Q 14f 3677642029 5 4 5 7 29.0 29.0

```
And `read_hitran_file` consequently crashes while trying to parse the empty lines. I temporarily fixed it by discarding empty lines with
```
if len(line) == 1: # line generated by 2 line return characters
continue
```
in `reader.py`:`read_hitran_file`, but of course, that's not the source of the problem.

My configuration:

```
Windows 64 bits, Python running under Anaconda 64 bits
astropy (2.0.3)
astroquery (0.3.8)
```

No problem under Linux (Ubuntu 64 bits)

Does this also happen to other Windows users?

Contributor guide

Open the contributing guide

Research direction

Start with download_hitran and read_hitran_file in reader.py, then reproduce the provided CO2 download and parsing sequence on Windows. Inspect the generated CO2.data line endings and confirm that read_hitran_file parses the downloaded data without empty-line errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.