Package PyML :: Package utils :: Module myio
[hide private]
[frames] | no frames]

Module myio

source code

Classes [hide private]
  UndoHandle
A Python handle that adds functionality for saving lines.
Functions [hide private]
 
load(fileName) source code
 
xmlLoad(fileName) source code
 
xmlSave(object, fileName) source code
 
save(object, fileName, binary=1) source code
 
csvwrite(a, fileName, delim=',')
write an array to a file in csv (comma-delimited) format
source code
 
csvread(fileName, delim=',')
read a character array from a file in csv format
source code
 
csvreadArray(fileName, type='float')
read an array from a file in csv format into a numpy array
source code
 
dlmreadArray(fileName, delimiter=' ', type='float')
read an array from a delimited file into a numpy array.
source code
 
tableWrite(t, fileName=None, **args)
Output a table out of a list of lists; elements number i of each list form row i of the table Usage : tableWrite((list1,list2...)) - write table to stdout tableWrite((list1,list2...), fileName) - write table to file
source code
 
dlmWrite(t, fileName, delim=',') source code
 
writeDict(dict, fileName, delim=',')
write a dictionary into a file as a set of pairs of key,value
source code
 
subDict(dict, list) source code
 
concatenateFiles(fileName1, fileName2, fileName3, delim=' ')
Horizontal concatenation of of two delimited files into a third file the delimiter is a space by default
source code
 
datasetIntersect(datasetSourceName, datasetIntersectName, newDatasetName)
keep the patterns in the source dataset that appear in the intersect dataset
source code
 
datasetUnion(datasetName1, datasetName2, newDatasetName)
assumes that the features in the two datasets have different names!
source code
 
makeDataSet(XfileName, labelsFileName, datasetFileName)
make a sparse format data file out of an unlabeled sparse data file and a labels file (comma delimited: id,label)
source code
 
formatMotifData(motifFileName, labelsFileName, svmFormatFileName, motifSpecFile=None) source code
 
formatMotifX(motifFileName, XfileName, motifSpecFile=None) source code
 
dlmExtract(inFile, outFields, outFile=None, convert=True, filterFile=None, filterField=None, inDelim=',', outDelim=',')
Extract from a delimited file a list of fields to another delimited file Input: inFile - file name with the input data outFields - a list of fields to extract from inFile outFile - output file convert - whether to convert numeric inputs from strings inDelim - the delimiter in the input file outDelim - the delimiter for the output file
source code
 
countLines(fileName) source code
 
extractLines(fileName, lines)
extract the lines given by a list of line numbers in the file
source code
 
splitFile(fileName, numFiles) source code
 
log(message, fileName='progress.log', openMode='a') source code
 
isempty(fileName) source code
 
findDelimiter(fileName)
guess the delimiter of a delimited file according to the first line in the file
source code
 
removeEmpty(directory)
remove all files that have size 0 from a directory
source code
 
selectLines(infile, outfile, lines, keepLines=1)
write to outfile the lines in infile whose line number is in the given list of line numbers
source code
 
return2newLine(inFile, outFile=None)
convert to (windows file to linux file)
source code
 
concatByNum(filePattern, outfileName, directory='.')
filePattern -- a regular expression that looks like: start\d+.dat
source code
 
myopen(fileName)
returns a file handle to a file which is possibly compressed using either gzip or bz2
source code
Function Details [hide private]

dlmreadArray(fileName, delimiter=' ', type='float')

source code 

read an array from a delimited file into a numpy array. all lines are assumed to have the same number of columns

myopen(fileName)

source code 

    returns a file handle to a file which is possibly compressed
    using either gzip or bz2

    myopen tries to open the file as a gzip file or a bz2 file.
    if unsuccessful with either it opens it with the standard open
    command in 'U' that uses universal newline support (i.e. all 
    variations on 
 yield 
.  it returns the resulting file handle.