[vtkusers] file readers: determine file type before Update()?

Nico Schlömer nico.schloemer at gmail.com
Tue May 15 09:05:32 EDT 2012


Hi,

for reading data from VTK/pVTK/Exodus/... files, is there any way to
determine the file format before calling Update() on the reader (and
error out)?
What I've currently got is

    if extension == '.vtu':
        # Set up VTU reader
    elif extension == '.vtk':
        # Set up VTK reader
    elif extension in [ '.ex2', '.exo', '.e' ]:
        # Set up exodus reader
    else:
        raise RuntimeError( 'Unknown file type \'%s\'.' % filename )

but this is going wrong if the extension doesn't coincide with the
file type, and is getting messy for parallel file format.

Any hints?

Cheers,
Nico



More information about the vtkusers mailing list