skip to navigation
skip to content

PyCifRW 3.6.2

CIF/STAR file support for Python

Latest Version: 4.1

PyCIFRW Readme


PyCIFRW provides support for reading and writing CIF (Crystallographic
Information Format) files using Python. It was developed at the
Australian National Beamline Facility (ANBF), run by the Australian
Synchrotron Research Program (ASRP), as part of a larger project to
provide CIF input/output capabilities for data collection. It is
currently (Aug 2007) under active development and testing.


The CIF 1.1 working specification was used as a reference, and in most
cases the grammar and character sets specified there were copied

PyCifRW has been tested on the IUCr sample CIF trip files located at and fails or
successfully reads as it is supposed to (note that ciftest5 contains
characters now forbidden in CIFs). Attempts to add an overlength
dataname to a CIF file currently resident in memory will result in an error.
Output lines do not exceed 2048 characters.

Supported Platforms

PyCIFRW is written entirely in Python. While this makes parsing of large
CIF files rather slow, it will run wherever Python runs. It has been
tested on Linux and Windows XP under Python 2.7.

A compiled extension module is available under Linux and Windows to
accelerate CIF file reading.


PyCiFRW consists of the following files:

Original files: Defines the CifFile module for Python
CifFile.nw Noweb file from which is obtained
CifFile.html Programming notes for CifFile derived also from
CifFile.nw Defines the StarFile module on which CifFiles are built
StarFile.nw Noweb file from which is obtained
StarFile.html Programming notes for also derived from StarFile.nw Cif parser automatically generated by Yapps2
YappsStarParser.g Grammar specifications for input to Yapps2
YappsStarParser.html Programming notes for the grammar
YappsStarParser.nw Literate format grammar notes
Makefile How to derive .html, .py and .g files from .nw files Compiled Python extension module for Linux
StarScan.pyd Compiled Python extension module for Windows

Files derived from other programs: Yapps2 runtime support (modified part of the
Yapps2.1.1 distribution)




See the text in Programming_Manual.html for details of the interface.
Essentially, cif files look like python dictionaries, with each
entry in the dictionary corresponding to a data block. The blocks
themselves are also dictionaries, with each data name being a
single entry in the dictionary, so for example,
cf['si_std']['_diffrn_meas_wavelength'] will return the value of
_diffrn_meas_wavelength in the data block named si_std of the Cif file object


To read in a CIF:
>> from CifFile import *
>> cf = CifFile.ReadCif('jun_01_2.cif')

to access information in a CIF

>> wav = cf['si_std']['_diffrn_meas_wavelength']

to set a value

>> cf['si_std']['_diffrn_meas_wavelength'] = 1.54

Extra programs

The "Programs" directory contains program "" which
validates a data files against data dictionaries. Execute this file
without arguments for a help message.
File Type Py Version Uploaded on Size
PyCifRW- (md5) Python Egg 2.7 2015-02-19 138KB
PyCifRW- (md5) Source 2015-02-19 430KB
  • Downloads (All Versions):
  • 8 downloads in the last day
  • 218 downloads in the last week
  • 1069 downloads in the last month