Skip to content
Advertisement

Do you know a Python module to read Universal File Format (UFF)? [closed]

Google wasn’t my friend this time.

This is the closest to a doc I can find : http://go-ci.com/note/new/note_401.html. The guys who created that should have something at http://sdrl.uc.edu/UFF2/58.asc but it’s a 404.

UFF is apparently a format used by scientific softwares. This is not widely used but some old handcrafted programs require it.

Please take note that for now, the question is not what I should do with the old programs or to the old programmers responsible for this :-p

Advertisement

Answer

If you’re referring to these many “universal file formats”, e.g. universal dataset 58 and the many other numbered datasets, I don’t think there are any Python libraries to read them directly. I think you’ll have to write your own code, depending on what numbers of “universal dataset” you need.

It’s going to be some work, but perhaps not that terrible: the various formats are all documented in/for Fortran IV (gives you an idea of the approximate age of those formats…!), so they’re not hard to interpret if you know the Fortran FORMAT notation. For example, in UDV 58, the first few lines are documented as

Record 1:     Format(80A1)

meaning “80 bytes to be interpreted as a single [[ASCII]] text-byte string”; a few lines down,

Record 6:     Format(2(I5,I10),2(1X,10A1,I10,I4))

means “twice a 5-digit integer followed by a 10-digit integer; then twice a space, a 10-byte ascii string, a 10-digit integer, a 4-digit integer” and the following lines in the doc explain the meaning of the ten fields (the space, 1X, is not explained;-) — the function type, with a code of 0 for general or unknown, 1 for time response, 2 for auto spectrum, … all the way to 27 for order function or 28 for phase compensation; then the function identification number; and so on, and so forth.

Fortran IV FORMAT statement format is not all that complicated and is widely documented, e.g. here. Alternatively, you could write very simple Fortran code which just applies the sequence of formats as given in those documents, and make it into a Python extension with f2py (or maybe pyfortran, but I think the latter has not been maintained in the last few years as Paul Dubois retired).

One more possibility: python-fortranformat is specifically a tool for using fortran format statements in Python. It’s a “work in progress” but is reasonably stable now. Install with easy_install -U fortranformat.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement