pytups.utils.Parser package

Submodules

pytups.utils.Parser.StandardParser module

class pytups.utils.Parser.StandardParser.DataFetcher[source]

Bases: object

Standard parser for fetching and parsing external data files.

static fetch_data(file_url)[source]
class pytups.utils.Parser.StandardParser.StandardParser(url=None)[source]

Bases: object

StandardParser encapsulates the complete workflow for downloading and parsing a NOAA text file.

The class maintains attributes such as the URL, file lines, metadata boundaries, extracted variable names, header skip count, parsed data, and the final DataFrame.

url

The URL of the file to parse.

Type:

str

lines

The content of the file split into lines.

Type:

list of str

meta_start

The index of the first metadata line.

Type:

int

meta_end

The index of the last metadata line.

Type:

int

variables

The extracted variable names.

Type:

list of str

skip_lines

The number of header lines to skip in the data block.

Type:

int

data

The parsed data rows.

Type:

list of list of str

df

The constructed DataFrame.

Type:

pandas.DataFrame

parse(url=None)[source]

Execute the full parsing workflow and return the constructed DataFrame.

_fetch_file()[source]

Fetch the file and set the ‘lines’ attribute.

_identify_metadata()[source]

Identify metadata boundaries and set ‘meta_start’ and ‘meta_end’.

_extract_variables()[source]

Extract variable names and header skip count, setting ‘variables’ and ‘skip_lines’.

_parse_data()[source]

Parse the data block from the file and set the ‘data’ attribute.

_construct_dataframe()[source]

Construct the final DataFrame from parsed data and variables.

parse(url=None)[source]

Orchestrate the full parsing process.

Parameters:

url (str, optional) – The URL to parse. If provided, it overrides the existing URL attribute.

Returns:

The constructed DataFrame.

Return type:

pandas.DataFrame

Raises:

ParsingError – If any step of the parsing process fails.

Module contents