Fix conditional header generation for NMR JCAMP export #219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses an issue where certain JCAMP files, like 356_MR260_NaCp_UHV_1H.jcamp.txt, could be opened directly in NMRium but failed to load through the ELN. Specifically, the NMRium button is enabled; however, when clicked, it only displays the placeholder drag-and-drop screen instead of loading the actual data.
Context:
The root cause was identified in the __header_nmr method in chem_spectra/lib/composer/ni.py, which previously attempted to add headers unconditionally. When any data field was missing, this led to inconsistencies and failed parsing by NMRium.
Solution: This PR modifies the __header_nmr method to conditionally include each header line only if the corresponding data is present. This prevents incomplete or empty header lines that could disrupt the JCAMP file format.
Changes:
Testing:
This fix will ensure that NMRium parse the file correctly when accessed via the ELN.
Issue : data not loaded into nmrium #221