roxieapi.input.parser module¶
- class roxieapi.input.parser.RoxieInputParser(inputlines: Iterable[str])[source]¶
Bases:
object
Class RoxieInputParser parses a roxie file
- static from_datafile(inputfile)[source]¶
Construct a new RoxieInputParser from Roxie .data file :param inputfile: Roxie .data file :return: A RoxieInputParser object with parsed content
- get_block(blockname)[source]¶
Return the data of a block :param blockname: The name of the block :return A filled Dataframe for regular blocks, a list of Daraframes for “special” blocks,
or an empty Dataframe of no block was initialized
- roxieapi.input.parser.convert_bottom_header_table_to_str(block_df: DataFrame, keyword: str, line_suffix='', header_suffix='') str [source]¶
Function converting a dataframe with a keyword and suffix to string. The string is used to create a ROXIE .data input file.
- Parameters:
block_df – a dataframe with content to be converted into a bottom header table string
keyword – a keyword for the table
line_suffix – a string added at the end of each of line to match the ROXIE formatting
- Returns:
a string representation of a bottom header table
- roxieapi.input.parser.convert_table_to_str(block_df: DataFrame, keyword: str, header_suffix='') str [source]¶
Function converting a dataframe with a keyword and suffix to string without bottom header columns. The string is used to create a ROXIE .datainput file.
- Parameters:
block_df – a dataframe with content to be converted into a bottom header table string
keyword – a keyword for the table
line_suffix – a string added at the end of each of line to match the ROXIE formatting
- Returns:
a string representation of a bottom header table
- roxieapi.input.parser.extract_bottom_header_table(text_file_lines: List[str], index_start: int, n_lines: int) DataFrame [source]¶
Function extracting a bottom header template from ROXIE .data and .cadata files. The method requires a start index in the table as well as the number of lines the table occupies.
- Parameters:
text_file_lines – an input list of lines from a ROXIE .data or .cadata file
index_start – an index where the table starts
n_lines – the number of lines occupied by the table
- Returns:
a dataframe with the table
- roxieapi.input.parser.extract_nested_bottom_header_table(text_file_lines: List[str], index_start: int, n_lines: int)[source]¶
Function extracting a bottom header template from ROXIE .data and .cadata files. The method requires a start index in the table as well as the number of lines the table occupies.
- Parameters:
text_file_lines – an input list of lines from a ROXIE .data or .cadata file
index_start – an index where the table starts
n_lines – the number of lines occupied by the table
- Returns:
a dataframe with the table
- roxieapi.input.parser.find_index_start_and_length_bottom_header_table(output_lines: List[str], table_keyword: str) Tuple[int, int] [source]¶
Function finding the start and length of a table in ROXIE .output or .cadata or .data file. If a table keyword can’t be found, the an IndexError is thrown.
- Parameters:
output_lines – a list of lines read from a ROXIE file
table_keyword – a keyword for the objective table
- Returns:
a tuple with an index of the start of bottom header table and its length
- roxieapi.input.parser.read_bottom_header_table(roxie_file_path: str, keyword='CABLE') DataFrame [source]¶
Function reading a bottom header table from ROXIE .data, .cadata, .output files
- Parameters:
roxie_file_path – a path to a roxie file
keyword – a table keyword
- Returns:
a dataframe with content of a table given by a keyword
- roxieapi.input.parser.read_nested_bottom_header_table(roxie_file_path: str, keyword='LAYER') DataFrame [source]¶
Function reading a bottom header table from ROXIE .data, .cadata, .output files
- Parameters:
roxie_file_path – a path to a roxie file
keyword – a table keyword
- Returns:
a nested dataframe with content of a table given by a keyword