carputils.carpio.txt.TxtFile

class carputils.carpio.txt.TxtFile(filename, mode='r')

file IO class for reading ascii files with extensions - dat(.gz) - elem - vec(.gz) - vtx - pts

Direct read/write to gzipped files is possible. The class automatically determines if the file is gzipped by its extension.

This class is little more than an elaborate wrapper for the numpy loadtxt and savetxt functions, but is included for completeness in the carputils.carpio module.

Args:
filename : str
The filename to open
mode : str, optional
‘r’ for read mode (default), ‘w’ for write mode
close()

Close the file object.

data()

Return a numpy array of the file contents.

Returns:
numpy.ndarray
A numpy array with the file contents
write(data, **kwargs)

Write a numpy array to a .dat or .vec file.

Args:
data : numpy.ndarray
The array to be written to the IGB file