Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SDF to CSV Converter

Convert one or more SDF files into CSV tables using RDKit.

The script extracts molecule properties from SDF records, adds a molecule index, computes canonical SMILES, and attempts to generate an InChIKey for each readable molecule.

Features

  • Accepts individual SDF files, directories, or glob patterns.
  • Writes one CSV per SDF by default.
  • Can combine multiple SDF files into one CSV.
  • Recursively searches directories for .sdf files.
  • Attempts to continue when individual molecules cannot be sanitized.
  • Adds mol_index, Name, SMILES, and InChIKey columns.

Requirements

  • Python 3.8+
  • pandas
  • RDKit

Recommended installation with conda:

conda install -c conda-forge rdkit pandas

Basic Usage

Convert a single SDF file:

python sdf2csv.py compounds.sdf

This writes:

compounds.csv

in the current directory.

Output Directory

Write the CSV file to a specific folder:

python sdf2csv.py compounds.sdf --outdir csv_out

or:

python sdf2csv.py compounds.sdf -o csv_out

Convert Multiple Files

Convert all SDF files in a folder:

python sdf2csv.py sdf_files --outdir csv_out

Convert files matching a pattern:

python sdf2csv.py *.sdf --outdir csv_out

Combine Outputs

Combine all input SDF files into a single CSV:

python sdf2csv.py sdf_files --outdir csv_out --combine

Set the combined output filename:

python sdf2csv.py sdf_files --outdir csv_out --combine --outname all_compounds.csv

When --combine is used, the output includes a source_file column.

Verbose Mode

Print progress and warnings:

python sdf2csv.py sdf_files --outdir csv_out --verbose

Output Columns

The script prioritizes these columns:

  • mol_index
  • Name
  • SMILES
  • InChIKey

Any additional SDF properties are preserved as extra CSV columns.

Notes

Unreadable molecules are skipped with warnings. If a molecule cannot be sanitized, the script still tries to extract available properties and compute SMILES/InChIKey.

About

Easily read your in silico results by converting SDF files to CSV

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages