Author: bugman Date: Thu Nov 22 12:39:37 2007 New Revision: 3819 URL: http://svn.gna.org/viewcvs/relax?rev=3819&view=rev Log: Updated the extract_data() for the new relax design (converted from a class method to a function).
Modified: 1.3/relax_io.py Modified: 1.3/relax_io.py URL: http://svn.gna.org/viewcvs/relax/1.3/relax_io.py?rev=3819&r1=3818&r2=3819&view=diff ============================================================================== --- 1.3/relax_io.py (original) +++ 1.3/relax_io.py Thu Nov 22 12:39:37 2007 @@ -56,6 +56,32 @@ This includes IO redirection, automatic loading and writing of compressed files (both Gzip and BZ2 compression), reading and writing of files, processing of the contents of files, etc. """ + + +def extract_data(file_name=None, dir=None, file_data=None, sep=None, compress_type=0): + """Open the file 'file' and return all the data.""" + + # Data not already extracted from the file. + if not file_data: + # Open the file. + file = open_read_file(file_name=file_name, dir=dir, compress_type=compress_type) + + # Read lines. + file_data = file.readlines() + + # Create a data structure from the contents of the file split by either whitespace or the separator, sep. + data = [] + for i in xrange(len(file_data)): + if sep: + row = split(file_data[i], sep) + else: + row = split(file_data[i]) + data.append(row) + return data + + # Close the file. + if not file_data: + file.close() def get_file_path(file_name=None, dir=None): @@ -297,32 +323,6 @@ remove(file_path) - def extract_data(self, file_name=None, dir=None, file_data=None, sep=None, compress_type=0): - """Open the file 'file' and return all the data.""" - - # Data not already extracted from the file. - if not file_data: - # Open the file. - file = self.open_read_file(file_name=file_name, dir=dir, compress_type=compress_type) - - # Read lines. - file_data = file.readlines() - - # Create a data structure from the contents of the file split by either whitespace or the separator, sep. - data = [] - for i in xrange(len(file_data)): - if sep: - row = split(file_data[i], sep) - else: - row = split(file_data[i]) - data.append(row) - return data - - # Close the file. - if not file_data: - file.close() - - def file_root(self, file_path): """Return the root file name, striped of path and extension details""" _______________________________________________ relax (http://nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits