Converting GC/MS data from NetCDF to CSV

/

NetCDF is a binary file format [1]. A NetCDF file opened in a text editor looks like a chaotic set of characters. In this case, only the names of dimensions, variables, and attributes remain readable.

There are several ways to make a NetCDF file readable. The ncdump utility [2] or an Excel macro [3] can be used to convert data to text format. However, it does not really help, because all recorded m/z values and their intensities are represented as elements of two one-dimensional arrays (mass_values and intensity_values). The size of these arrays usually exceeds hundreds of thousands of elements. As a result, it becomes practically impossible to manually extract the necessary information (for example, the mass spectrum corresponding to the n‑th scan).

The cdf2csv command-line utility was written in C to simplify the process of converting GC/MS data from NetCDF to CSV format. The utility is based on libraries developed by the University Corporation for Atmospheric Research [4]. The utility uses a list separator specified in the "Regional and Language Options".

 

Converting NetCDF to CSV format using the cdf2csv utility:

  1. Put the NetCDF file and cdf2csv utility in the same directory
  2. Run the cdf2csv utility.
  3. Enter the file name (and its extension), when the message "Enter the file name" appears. Press the Enter key.
  4. If the file is read without any error, the information extracted from the file is displayed:
    • scan_number - the number of scans
    • point_number - the total number of elements represented in the mass_values and intensity_values arrays
    • global_mass_min - the minimum m/z value of the entire file
    • global_mass_max - the maximum m/z value of the entire file
  5. When the message "Export all data (a) or some segment (s)" appears press the 'a' key to convert the entire file or press the 's' key to convert a particular fragment (in this case, you need to enter the initial and final scan number of the GC/MS fragment).
  6. The message "File conversion has been completed" appears if the file has been successfully converted.