pyamr.utils.io package

Submodules

pyamr.utils.io.read module

Author: Bernard Hernandez Filename: Date: Description:

Functions:

files_with_extension(folder, ext)

This method return files with extension.

read_csv(path, **kwargs)

This method...

read_csv_file(path[, rename_map, std_cols, ...])

This method reads a csv file.

read_csv_folder(path, **kwargs)

Load all excel files into a pandas dataframe.

read_data(ftype, **kwargs)

This method loads data from the specified format.

read_excel(path)

This function...

read_excel_file(path[, rename_map, std_cols])

This method...

read_excel_folder([path])

Load all excel files into a pandas dataframe.

read_mysql_server([url, query, rename_map])

This function rename codes (i.e.

pyamr.utils.io.read.files_with_extension(folder, ext)[source]

This method return files with extension.

Parameters:
  • folder (path containing the files.)

  • ext (selected extensions.)

Returns:

ext_files

Return type:

files in folder with the extensions in ext.

pyamr.utils.io.read.read_csv(path, **kwargs)[source]

This method…

pyamr.utils.io.read.read_csv_file(path, rename_map={}, std_cols=None, keep_cols=None, date_cols=[], **kwargs)[source]

This method reads a csv file.

Note: 1. It uses the pandas function pd.read_csv.

Note: keep_cols is used instead of default usecols from pandas because when reading different files we cannot ensure that all have the same column names before renaming.

Parameters:
  • rename_map

  • std_cols

  • keep_cols

  • date_cols

pyamr.utils.io.read.read_csv_folder(path, **kwargs)[source]

Load all excel files into a pandas dataframe.

Parameters:
  • folder

  • rename_map

  • std_cols

pyamr.utils.io.read.read_data(ftype, **kwargs)[source]

This method loads data from the specified format.

Parameters:
  • ftype (type of files to be load. Currently supported (xls, xlsx, csv, mysql).)

  • rename_map (dict-like, with current name and desired name.)

  • std_cols (list of columns that want to be kept.)

  • url (Only for ‘mysql’ - url to connect to the mysql sever.)

  • query (Only for ‘mysql’ - query to be executed against the server.)

Return type:

dataframe - <DataFrame> from pandas with content.

pyamr.utils.io.read.read_excel(path)[source]

This function…

pyamr.utils.io.read.read_excel_file(path, rename_map={}, std_cols=None, **kwargs)[source]

This method…

pyamr.utils.io.read.read_excel_folder(path=None, **kwargs)[source]

Load all excel files into a pandas dataframe.

Parameters:

path

pyamr.utils.io.read.read_mysql_server(url=None, query=None, rename_map=None)[source]

This function rename codes (i.e. PAER1,PAER2 to PEAR)

Module contents