py_everything.fileIO

Source code: py_everything/fileIO.py

This module deals with files and their input/output operations. With a wide range of functions.

py_everything.fileIO.readFile(fileName)

This method reads data from fileName.

Parameters

fileName (str) – Full path to the file to be read.

Returns str

Data of the file.

py_everything.fileIO.writeFile(fileName, writeData)

This method writes new data - writeData on to fileName

Parameters
  • fileName (str) – Full path to the file to writen to.

  • writeData (str) – Data to be written on to the file.

Returns bool

True if data was successfully written to file.

Changed in version 2.0.0: Raises TypeError if writeData type is not str

Note

This method deletes any previous data on the file. Before writing to it.

py_everything.fileIO.clearFile(fileName)

This method removes all data from fileName.

Parameters

fileName (str) – Full path to the file to be cleared.

Returns bool

True if file is cleared successfully.

py_everything.fileIO.mkDir(dirName, path)

Creates a new directory named dirName inside path.

Parameters
  • dirName (str) – Name of the directory to be created.

  • path (str) – Full path where directory is to be created.

Returns bool

True if directory is created successfully.

py_everything.fileIO.mkFile(fileName, path)

Creates a new file named fileName inside path.

Parameters
  • fileName (str) – Name of the file to be created.

  • path (str) – Full path where file is to be created.

Returns bool

True if file is created successfully.

py_everything.fileIO.delDir(path, dirName)

Deletes an existing directory named dirName from path.

Parameters
  • dirName (str) – Name of the directory to be deleted.

  • path (str) – Full path where directory is located.

Returns bool

True if directory is deleted successfully.

Note

This function is for empty directories only, for directories containing files or subfolders, see the next method.

py_everything.fileIO.delDirRec(path, dirName)

Deletes an existing directory named dirName from path recursively.

Parameters
  • dirName (str) – Name of the directory to be deleted.

  • path (str) – Full path where directory is located.

Returns bool

True if directory is deleted successfully.

py_everything.fileIO.delFile(path, fileName)

Deletes an existing file named fileName from path.

Parameters
  • dirName (str) – Name of the file to be deleted.

  • path (str) – Full path where file is located.

Returns bool

True if file is deleted successfully.