BaseSplitter

class astropy.io.ascii.core.BaseSplitter [edit on github][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
Parameters:delimiter – one-character string used to separate fields

Attributes Summary

delimiter

Methods Summary

process_line(line) Remove whitespace at the beginning or end of line.
process_val(val) Remove whitespace at the beginning or end of value.
join(vals)

Attributes Documentation

delimiter = None

Methods Documentation

process_line(line) [edit on github][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) [edit on github][source]

Remove whitespace at the beginning or end of value.

join(vals) [edit on github][source]

Page Contents