This Python script batch-processes binary .PRN
files and converts them into clean .CSV
files for easier analysis.
- Reads binary
.PRN
files containing 32-bit floating-point values. - Drops initial 29 records (often metadata or calibration noise).
- Outputs clean CSV files with a single
Spectrum
column. - Processes all
.PRN
files 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
.csv
using 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+
pandas
struct
os
pathlib
Install with:
pip install pandas
Each CSV will contain:
Spectrum |
---|
0.123456 |
0.654321 |
... |
This project is under the Creative Commons Zero v1.0 Universal license.