sasdata.dataloader.filereader module¶
This is the base file reader class most file readers should inherit from. All generic functionality required for a file loader/reader is built into this class
- class sasdata.dataloader.filereader.FileReader¶
Bases:
object
- allow_all = False¶
- convert_data_units(default_q_unit: str = '1/A')¶
Converts al; data to the sasview default of units of A^{-1} for Q and cm^{-1} for I. :param default_q_unit: The default Q unit used by Sasview
- data_cleanup()¶
Clean up the data sets and refresh everything :return: None
- ext = ['.txt']¶
- format_unit(unit: str = None) str ¶
Format units a common way :param unit: :return:
- abstractmethod get_file_contents()¶
Reader specific class to access the contents of the file All reader classes that inherit from FileReader must implement
- handle_error_message(msg: str)¶
Generic error handler to add an error to the current datainfo to propagate the error up the error chain. :param msg: Error message
- has_converter = True¶
- nextline() str ¶
Returns the next line in the file as a string.
- nextlines() str ¶
Returns the next line in the file as a string.
- read(filepath: str | Path, file_handler: CustomFileOpen | None = None, f_pos: int | None = 0) List[Data1D | Data2D] ¶
Basic file reader
- Parameters:
filepath – The string representation of the path to a file to be loaded. This can be a URI or a local file
file_handler – A CustomFileOpen instance used to handle file operations
f_pos – The initial file position to start reading from
- Returns:
A list of Data1D and Data2D objects
- readall() str ¶
Returns the entire file as a string.
- remove_empty_q_values()¶
Remove any point where Q == 0
- reset_data_list(no_lines: int = 0)¶
Reset the plottable_1D object
- reset_state()¶
Resets the class state to a base case when loading a new data file so previous data files do not appear a second time
- send_to_output()¶
Helper that automatically combines the info and set and then appends it to output
- set_all_to_none()¶
Set all mutable values to None for error handling purposes
- static set_default_1d_units(data: Data1D | Data2D) Data1D | Data2D ¶
Set the x and y axes to the default 1D units :param data: 1D data set :return:
- static set_default_2d_units(data: Data1D | Data2D) Data1D | Data2D ¶
Set the x and y axes to the default 2D units :param data: 2D data set :return:
- sort_data()¶
Sort 1D data along the X axis for consistency
- static splitline(line: str) List[str] ¶
Splits a line into pieces based on common delimiters :param line: A single line of text :return: list of values
- type = ['Text files (*.txt|*.TXT)']¶
- type_name = 'ASCII'¶
- sasdata.dataloader.filereader.decode(s)¶