BaseSplitter#

class astropy.io.ascii.BaseSplitter[source]#

Bases: object

Base splitter that uses python’s split method to do the work.

This does not handle quoted values. A key feature is the formulation of __call__ as a generator that returns a list of the split line values at each iteration.

There are two methods that are intended to be overridden, first process_line() to do pre-processing on each input line before splitting and process_val() to do post-processing on each split string value. By default these apply the string strip() function. These can be set to another function via the instance attribute or be disabled entirely, for example:

reader.header.splitter.process_val = lambda x: x.lstrip()
reader.data.splitter.process_val = None

Attributes Summary

delimiter

one-character string used to separate fields

Methods Summary

__call__(lines)

Call self as a function.

join(vals)

process_line(line)

Remove whitespace at the beginning or end of line.

process_val(val)

Remove whitespace at the beginning or end of value.

Attributes Documentation

delimiter = None#

one-character string used to separate fields

Methods Documentation

__call__(lines)[source]#

Call self as a function.

join(vals)[source]#
process_line(line)[source]#

Remove whitespace at the beginning or end of line. This is especially useful for whitespace-delimited files to prevent spurious columns at the beginning or end.

process_val(val)[source]#

Remove whitespace at the beginning or end of value.