This Python script batch-processes binary .PRN files and converts them into clean .CSV files for easier analysis.
- Reads binary
.PRNfiles containing 32-bit floating-point values. - Drops initial 29 records (often metadata or calibration noise).
- Outputs clean CSV files with a single
Spectrumcolumn. - Processes all
.PRNfiles in a specified input directory.
inputprnswc/ # Put your .PRN files here
outputcsvswc/ # CSVs will be saved here after conversion
- Reads binary data in 4-byte chunks (single float per chunk).
- Converts values into a list of dictionaries.
- Skips the first 29 entries.
- Writes the rest into a
.csvusing pandas.
Just update the paths and run:
input_folder = r"inputprnswc"
output_folder = r"outputcsvswc"
process_all_prn_files(input_folder, output_folder)- Python 3.6+
pandasstructospathlib
Install with:
pip install pandasEach CSV will contain:
| Spectrum |
|---|
| 0.123456 |
| 0.654321 |
| ... |
This project is under the Creative Commons Zero v1.0 Universal license.