pysal

This Page

IOHandlers.gal — GAL Plugin for PySAL’s FileIO System

New in version 1.0.

class pysal.core.IOHandlers.gal.GalIO(*args, **kwargs)

Opens, reads, and writes file objects in GAL format.

Examples

>>> import tempfile, pysal, os
>>> w = pysal.open('../../examples/sids2.gal','r').read()
>>> f = tempfile.NamedTemporaryFile(suffix='.gal')
>>> fname = f.name
>>> f.close()
>>> o = pysal.open(fname,'w')
>>> o.write(w)
>>> o.close()
>>> wnew =  pysal.open(fname,'r').read()
>>> wnew.pct_nonzero == w.pct_nonzero
True
>>> os.remove(fname)

Methods

by_row
cast
check
close
flush
get
getType
next
open
read
seek
tell
truncate
write
class by_row(parent)
GalIO.cast(key, typ)
cast key as typ
classmethod GalIO.check()
Prints the contents of the registry
GalIO.close()
GalIO.data_type
GalIO.flush()
GalIO.get(n)
Seeks the file to n and returns n If .ids is set n should be an id, else, n should be an offset
static GalIO.getType(dataPath)
Parse the dataPath and return the data type
GalIO.ids
GalIO.next()
A FileIO object is its own iterator, see StringIO
classmethod GalIO.open(*args, **kwargs)
Alias for FileIO()
GalIO.rIds
GalIO.read(n=-1)
GalIO.seek(pos)
GalIO.tell()
Return id (or offset) of next object
GalIO.truncate(size=None)
Should be implemented by subclasses and redefine this doc string
GalIO.write(obj)
Parameters:

.write(weightsObject) :

accepts a weights object :

Returns :

—— :

a GAL file :

write a weights object to the opened GAL file. :