carputils
Doxygen code documentation for the python framework controlling openCARP
Public Member Functions | List of all members
carputils.carpio.txt.TxtFile Class Reference

file IO class for reading ascii files with extensions More...

Inheritance diagram for carputils.carpio.txt.TxtFile:
carputils.carpio.filelike.FileLikeMixin

Public Member Functions

def __init__ (self, filename, mode='r')
 
def count (self)
 
def close (self)
 Close the file object. More...
 
def data (self)
 Return a numpy array of the file contents. More...
 
def write (self, data, kwargs)
 Write a numpy array to a .dat or .vec file. More...
 
def check_ext (self, ext)
 
- Public Member Functions inherited from carputils.carpio.filelike.FileLikeMixin
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_val, exc_tb)
 

Detailed Description

file IO class for reading ascii files with extensions

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

Parameters
filenamestr The filename to open
modestr, optional 'r' for read mode (default), 'w' for write mode

Constructor & Destructor Documentation

◆ __init__()

def carputils.carpio.txt.TxtFile.__init__ (   self,
  filename,
  mode = 'r' 
)

Member Function Documentation

◆ check_ext()

def carputils.carpio.txt.TxtFile.check_ext (   self,
  ext 
)

◆ close()

def carputils.carpio.txt.TxtFile.close (   self)

Close the file object.

◆ count()

def carputils.carpio.txt.TxtFile.count (   self)

◆ data()

def carputils.carpio.txt.TxtFile.data (   self)

Return a numpy array of the file contents.

Returns
numpy.ndarray A numpy array with the file contents

◆ write()

def carputils.carpio.txt.TxtFile.write (   self,
  data,
  kwargs 
)

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

Parameters
datanumpy.ndarray The array to be written to the IGB file

The documentation for this class was generated from the following file: