This module provides functions for file input/output. These are all wrapper functions, based on existing functions in other Python classes. Functions are provided to save a two-dimensional array to a text file, load selected columns of data from a text file, load a column header line, compact strings to include only legal filename characters, and a function from the Python Cookbook to recursively match filename patterns.
See the __main__ function for examples of use.
Save a numpy array to a file, included header lines.
This function saves a two-dimensional array to a text file, with an optional user-defined header. This functionality will be part of numpy 1.7, when released.
Load selected column data from a text file, processing as specified.
This function loads column data from a text file, manipulating the data read in. The individual vector data must be given in columns in the file, with the abscissa (x-value) in first column (col 0 in Python) and any number of ordinate (y-value) vectors in second and later columns.
Note: leave only single separators (e.g. spaces) between columns! Also watch out for a single sapce at the start of line.
Loads column data from a text file, using the csv package.
Using the csv package, loads column header data from a file, from the firstrow. Headers must be delimited by commas. The function [LoadColumnTextFile] provides more comprehensive capabilties.
Clean a string by removing selected characters.
Creates a legal and ‘clean’ sourcestring from a string by removing some clutter and illegals. A default set is given but the user can override the default string.
Lists the files/directories meeting specific requirement
Searches a directory structure along the specified path, looking for files that matches the glob pattern. If specified, the search will continue into sub-directories. A list of matching names is returned.
Constructs a numpy array from data in a binary file with known data-type.
Write a numpy array to latex table format in output file.
The table can contain only the array data (no top header or left column side-header), or you can add either or both of the top row or side column headers. Leave ‘header’ or ‘leftcol’ as None is you don’t want these.
The output format of the array data can be specified, i.e. scientific notation or fixed decimal point.
Read a 2D lookup table and extract the data.
The table has the following format:
line 1: xlabel ylabel title line 2: 0 (vector of y (col) abscissa) lines 3 and following: (element of x (row) abscissa), followed by table data.From line/row 3 onwards the first element is the x abscissa value followed by the row of data, one point for each y abscissa value. The format can depicted as follows:
x-name y-name ordinates-name 0 y1 y2 y3 y4 x1 v11 v12 v13 v14 x2 v21 v22 v23 v24 x3 v31 v32 v33 v34 x4 v41 v42 v43 v44 x5 v51 v52 v53 v54 x6 v61 v62 v63 v64This function reads the file and returns the individual data items.