Thread: Reading an IR Spectrosopy File (.SPA file) (Unknown Binary File)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    117

    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;
    
    }
    Attached Files Attached Files
    My Ctrl+S addiction gets in the way when using Code Blocks...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading in file of unknown length
    By zone159 in forum C Programming
    Replies: 2
    Last Post: 11-14-2012, 02:07 PM
  2. unknown file type reading
    By xixonga in forum C Programming
    Replies: 20
    Last Post: 11-28-2010, 12:17 PM
  3. reading a file of unknown length
    By the bassinvader in forum C Programming
    Replies: 2
    Last Post: 07-12-2006, 03:06 PM
  4. Reading in a binary file from offset into another file
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 05-24-2006, 03:01 AM
  5. Unknown Error(c-lang), while reading a character from file
    By c_square in forum C++ Programming
    Replies: 2
    Last Post: 01-14-2005, 04:00 AM