1 Attachment(s)
Reading an IR Spectrosopy File (.SPA file) (Unknown Binary File)
I just took an IR of a compound I made (Propyl acetate) and saved the output to a file (it is in binary i believe).
There is the original file "jon_spec.SPA" and another file "binary.txt" where I just copied and pasted the nonsense in the text editor believing it is the binary that needs to be read.
It should look very similar to this: http://1.usa.gov/TWscPM
I do not know how the file is outputted, but to me the most logical way would just be a 1D Array with the values of the peaks at set intervals (lets say 1 cm^-1, that is the unit it is in).
In short, is there a way to read this data without knowing how it is structured?
I've tried playing around just loading 10/100 at a time seeing if it outputs anything useful (code below). When I use double it outputs integers, so probably saved the data as a short?
I know some of this is technical so if you need additional info please just ask :)
I'll also be contacting the manufacturer of this machine, hopefully they will let me know how the data is structured...
Thanks!!
Code:
// reading a complete binary file
#include <iostream>
#include <fstream>
using namespace std;
ifstream::pos_type size;
char * memblock;
int main ()
{
char character[100];
int integer[100];
long longint[100];
double doublefloat[100];
ifstream file ("binary.txt", ios::in|ios::binary|ios::ate); //jon_spec.SPA
if (file.is_open())
{
size = file.tellg();
memblock = new char [size];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();
int marker = 0;
for(int a = 0; a<10; a++)
{
doublefloat[marker] = (double)memblock[a];
cout << doublefloat[marker++] << endl;
}
delete[] memblock;
}
else cout << "Unable to open file";
return 0;
}