Previous topic

util.gimage

Next topic

util.gos

This Page

util.gio

Miscellaneous functions related to ASCII and pickled-binary file I/O.

glimpse.util.gio.CSV_DELIM = None

The CSV delimiter (defaults to any whitespace)

glimpse.util.gio.ENCODING_CSV = 'c'

Encoding ID for CSV-formatted text data.

glimpse.util.gio.ENCODING_FREE_TEXT = 's'

Encoding ID for free-formatted text data (used for output).

glimpse.util.gio.ENCODING_PICKLE = 'p'

Encoding ID for pickled data.

glimpse.util.gio.INPUT_ENCODINGS = ('p', 'c')

The set of all input encodings.

glimpse.util.gio.Load(fname=<open file '<stdin>', mode 'r' at 0x403b1020>, encoding='p')

Return the first object in a file.

glimpse.util.gio.LoadAll(fnames, encoding='p')

Read all objects in a set of files.

Parameters:
  • fnames (list of str) – Set of files to read.
  • encoding – Encoding of input files.
Returns:

Iterator over the set of all objects read.

glimpse.util.gio.LoadByFileName(fname, *args)

Load data from a file.

If the filename ends in ”.py”, then this function treats the file as python source. Otherwise, the file is treated as a pickled data object.

Parameters:
  • fname (str) – Path to file from which to read script.
  • args – The file encoding (for files not ending in ”.py”).
glimpse.util.gio.LoadPython(fname)

Load a file of Python source as a dictionary.

Parameters:fname (str) – Path to file from which to read script.
Returns:All global variables set by the script.
Return type:dict
glimpse.util.gio.OUTPUT_ENCODINGS = ('p', 'c', 's')

The set of all output encodings.

glimpse.util.gio.ReadGTiffFile(fname)

Read a file in GTiff format as an array.

Parameters:fname (str) – Path to input file.
Return type:3D ndarray
glimpse.util.gio.ReadLines(fname_or_fh)

Returns lines of file as an array.

glimpse.util.gio.ReadMatrix(fname, sep=' ')

Read CSV data from a file.

Deprecated since version 0.1: Use numpy.loadtxt() instead.

glimpse.util.gio.Store(obj, fname=<open file '<stdout>', mode 'w' at 0x403b1078>, encoding='p')

Store a single object to a file.

glimpse.util.gio.SuppressStdout(callback, *args, **vargs)

Evaluate a function, ignoring the data written to stdout.

This works even if the code emitting data to stdout is in a compiled extension.

Parameters:
  • callback – Function to call.
  • args – Positional arguments to pass to function.
  • vargs – Keyword arguments to pass to function.
Returns:

Value returned by callback function.

glimpse.util.gio.WriteLines(lines, fname)

Write an array as lines of a file.

Any existing file data is destroyed.

glimpse.util.gio.WriteMatrix(matrix, fname, sep=' ')

Write CSV data to a file.

Deprecated since version 0.1: Use numpy.savetxt() instead.

glimpse.util.gio.WriteString(string, fname)

Write a string to a file.

Any existing file data is destroyed.