fileinput.nextfile()

fileinput.nextfile() Close the current file so that the next iteration will read the first line from the next file (if any); lines not read from the file will not count towards the cumulative line count. The filename is not changed until after the first line of the next file has been read. Before the first line has been read, this function has no effect; it cannot be used to skip the first file. After the last line of the last file has been read, this function has no effect.

fileinput.lineno()

fileinput.lineno() Return the cumulative line number of the line that has just been read. Before the first line has been read, returns 0. After the last line of the last file has been read, returns the line number of that line.

fileinput.isstdin()

fileinput.isstdin() Returns true if the last line was read from sys.stdin, otherwise returns false.

fileinput.isfirstline()

fileinput.isfirstline() Returns true if the line just read is the first line of its file, otherwise returns false.

fileinput.input()

fileinput.input(files=None, inplace=False, backup='', bufsize=0, mode='r', openhook=None) Create an instance of the FileInput class. The instance will be used as global state for the functions of this module, and is also returned to use during iteration. The parameters to this function will be passed along to the constructor of the FileInput class. The FileInput instance can be used as a context manager in the with statement. In this example, input is closed after the with statement is exite

fileinput.hook_encoded()

fileinput.hook_encoded(encoding) Returns a hook which opens each file with open(), using the given encoding to read the file. Usage example: fi = fileinput.FileInput(openhook=fileinput.hook_encoded("iso-8859-1"))

fileinput.hook_compressed()

fileinput.hook_compressed(filename, mode) Transparently opens files compressed with gzip and bzip2 (recognized by the extensions '.gz' and '.bz2') using the gzip and bz2 modules. If the filename extension is not '.gz' or '.bz2', the file is opened normally (ie, using open() without any decompression). Usage example: fi = fileinput.FileInput(openhook=fileinput.hook_compressed)

fileinput.fileno()

fileinput.fileno() Return the integer “file descriptor” for the current file. When no file is opened (before the first line and between files), returns -1.

fileinput.filename()

fileinput.filename() Return the name of the file currently being read. Before the first line has been read, returns None.

fileinput.filelineno()

fileinput.filelineno() Return the line number in the current file. Before the first line has been read, returns 0. After the last line of the last file has been read, returns the line number of that line within the file.