The mcr_file Module

Module used for converting CMS DAT files to CSV

log(s)[source]
width(s: str)[source]
exception MedparParseException(msg: str, pos: int)[source]

Exception raised if data in a DAT file cannot be parsed

class ColumnAttribute(start: int, end: int, conv)[source]

Attribute of a column as described in the FTS file

arg(line: str)[source]
class ColumnDef(pattern)[source]

Column definition as described in the FTS file

read(line)[source]
class Column(ord: int, long_name: str, short_name: str, type: str, start: int, width, desc: str)[source]

Class representing column metadata required for generating database schema

class MedicareFile(dir_path: str, name: str, year: Optional[str] = None, dest: Optional[str] = None)[source]

Class to manipulate a single CMS DAT file

init()[source]
read_record(data, ln) List[source]

Reads one record from DAT file

Parameters:
  • data – a slice of raw data from DAT file

  • ln – line number, used for reporting

Returns:

Record data as list

validate(record)[source]

Asserts that the given record is consistent with the file from which it is read.

Parameters:

record – Record

Returns:

None

count_lines_in_source()[source]

Counts number of lines in the original DAT file

Returns:

number of lines

count_lines_in_dest()[source]

Counts number of lines in the resulting CSV file

Returns:

number of lines

status() str[source]

Checks if a given DAT file has been successfully converted to CSV

Returns:

Value of the status of the conversion

status_message()[source]

Checks if a given DAT file has been successfully converted to CSV

Returns:

Message, containing the status of the conversion

export()[source]

Performs actual conversion

info()[source]

Prints info about the DAT file (metadata) to standard output