GithubHelp home page GithubHelp logo

dd-hebert / agilent-uvvis-to-csv Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 39 KB

A simple script to convert Agilent 845x Chemstation UV-Vis files (.KD or .SD formats) to .csv format. Fast and easy!

License: MIT License

Python 100.00%
agilent binary-files converter csv kd pandas python sd uv-vis chemistry

agilent-uvvis-to-csv's Introduction

uv2csv

A simple script for converting Agilent 845x Chemstation UV-vis binary files (.KD or .SD formats) to .csv format.

Do you have .KD or .SD UV-vis files but no access to the Agilent 845x UV-vis Chemstation software? Do you have large .KD files that contain thousands of spectra? This script will automatically convert your .KD or .SD files to .csv format (and it's significantly faster than the Agilent Chemstation software!). Exports thousands of spectra in seconds!

Currently supports .KD and .SD UV-vis binary file types.

Using This Script

To use this script, simply run it from the command line:

python uv2csv.py

Then provide a file path when prompted.

How It Works

This script works by searching a .KD or .SD file for a unique byte string which precedes the absorbance data (see disclaimer). The absorbance data that follows this byte string are encoded as little-endian double precision floats, which the script unpacks into a pandas DataFrame.

Export Location for .CSV Files

You can locate the exported .csv files in the same directory as the original .KD or .SD binary file.

  • Files with Multiple Spectra: .csv files are exported into a folder within the same directory as the binary file.
  • Files with a Single Spectrum: A single .csv file is exported to the same directory as the binary file.

Note: If the .SD file you are parsing contains sample names, the sample names will be included in the file names of the exported .csv files. Please be aware that sample names are not currently supported for .KD files.

Changing The Wavelength Range

By default, the script assumes your spectrometer captures data from 190 nm to 1100 nm. If the range of wavelengths your spectrometer records is different than this, you can set the wavelength range by adding a single keyword argument wavelength_range to the UVvisFile object constructor at the bottom of the script:

if __name__ == '__main__':
    PATH = os.path.normpath(input('Enter a file path or "q" to quit: '))
    UV_FILE = UVvisFile(PATH, export_csv=True, wavelength_range=(min, max))

Requirements

You must have the pandas python package installed to use this script.

Disclaimer

This script has only been tested on files from a small number of different versions of the Agilent UV-vis Chemstation software. Therefore, binary files from other versions of UV-vis Chemstation, different spectrometer setups, or custom methods may not work.

Known Supported Chemstation Versions:

  • B.05.02 [16]
  • A.08.03 [71]

If you encounter an bug or problem, please submit an issue so I can improve this script!

agilent-uvvis-to-csv's People

Contributors

dd-hebert avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

agilent-uvvis-to-csv's Issues

Sample Names

Hello again! This time I came not with a bug, but with a proposal. Is it possible to decode from SD files not only the absorption spectrum itself, but also the names of the samples? When reading SD files, I can find the approximate location of the sample names, but I have trouble decoding them. This would be quite useful, especially if you need to open some old files when no one remembers what specific position the required spectra were in

UnicodeDecodeError

Hi I talked to you a while ago about other of this errors, and it's happening again with a teacher's file that I'm converting.

So the error was UnicodeDecodeError: 'ascii' codec can't decode byte 0xd3 in position 1: ordinal not in range(128)

I will send the data that wasn't working with one that works (chlorphyll), sorry to bother again.
srry.zip

Agilent Chemstation 8453

Hello! Looking for tips on how to open Agilent files i came across your script that allows convert SD files to CSV. However, when I try to use it on my existing files (Agilent 8453), I get an attribute error. I've only recently started learning python, so I didn't delve into your code, but would like to ask for help. An example of few of these files is attached.
image
SSP.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.