diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py index dc609a7e40589f1afbc3d22c88533aec4ae8abf4..c770fdc9e8432e0ddb18894ba67891f179cbea1a 100644 --- a/modules/base/pymod/table.py +++ b/modules/base/pymod/table.py @@ -448,10 +448,26 @@ class Table: return filt_tab @staticmethod - def Load(stream): + def Load(stream_or_filename): + """ + Load table from stream or file with given name. The file must contain a + header line of the form + + col_name1[type1] <col_name2[type2]>... + + The types given in brackets must be one of the data types the :class:`Table` + class understands. Each following line in the file then must contains exactly + the same number of data items as listed in the header. The data items are + automatically converted to the column format. Lines starting with a '#' and + empty lines are ignored. + + :returns: A new :class:`Table` instance + """ fieldname_pattern=re.compile(r'(?P<name>[A-Za-z0-9_]+)(\[(?P<type>\w+)\])?') - if not hasattr(stream, 'read'): - stream=open(stream, 'r') + if not hasattr(stream_or_filename, 'read'): + stream=open(stream_or_filename, 'r') + else: + stream=stream_or_filename header=False num_lines=0 for line in stream: diff --git a/modules/index.rst b/modules/index.rst index 05c38c4dc9b944734eefbcf037196fe2f788ebc2..8cc338a82b9480f516d927e48b3894b80b61e8d0 100644 --- a/modules/index.rst +++ b/modules/index.rst @@ -26,7 +26,8 @@ OpenStructure documentation newmodule external contributing - + table + For Starters -------------------------------------------------------------------------------- @@ -85,7 +86,10 @@ Graphical User Interface **Widgets**: :doc:`python shell <gui/python_shell>` | :doc:`sequence viewer <gui/sequence_viewer>` +Varia +-------------------------------------------------------------------------------- +**Datasets:** :doc:`tabular data <table>` Extending OpenStructure --------------------------------------------------------------------------------