imhr.Webgazer.download

@purpose: Resource for downloading files from Box, SSH, REDCap and others.
@date: Created on Sat May 1 15:12:38 2019
@author: Semeon Risom

Classes

download([is_library]) Resource for downloading files from Box, SSH, REDCap and others.
class imhr.Webgazer.download.download(is_library=False)[source]

Bases: object

Resource for downloading files from Box, SSH, REDCap and others.

Methods

Methods

REDCap(path, token, url, content[, payload]) Download data from an Research Electronic Data Capture (REDCap) server.
SFTP(source, destination, hostname, …) Connect to a remote server using a Secure File Transfer Protocol (SFTP).
box(source, destination, server, username, …) Connect to Box cloud cloud storage service, using File Transfer Protocol over SSL (FTPS).
REDCap(path, token, url, content[, payload]) Download data from an Research Electronic Data Capture (REDCap) server.
SFTP(source, destination, hostname, …) Connect to a remote server using a Secure File Transfer Protocol (SFTP).
box(source, destination, server, username, …) Connect to Box cloud cloud storage service, using File Transfer Protocol over SSL (FTPS).
classmethod REDCap(path, token, url, content, payload=None, **kwargs)[source]

Download data from an Research Electronic Data Capture (REDCap) server.

Parameters:
path : str

Path to save data. For example:

>>> path = '/Users/mdl-admin/Desktop/r33/redcap'
token : str

The API token specific to your REDCap project and username. This is usually found on the Applications > API page. For example:

>>> token = 'D19859823032SFDMR24395298'
url : str

The URL of the REDCap project. For example:

>>> url = 'https://redcap.prc.utexas.edu/redcap/api/'.
content : str {report, file, raw, arm, instrument, returnFormat, metadata, project, surveyLink, user, participantList}

Type of export. Examples include exporting a report (report), file (file), or project info (project).

payload_ : dict or None, optional

Manually submit parameters for exporting or importing data. Can be entered within the function for convenience.

**kwargs : str or None, optional

Additional properties, relevent for specific content types. Here’s a list of available properties:

Property Description
report_id : str (report, record) The report ID number provided next to the report name on the report list page.
format_ : str {csv, json, xml, odm} Format to return data, either csv, json, xml, or odm. Default is json.
type_ : str Shape of data. Default is flat.
rawOrLabel_ : str {raw, label} (report, record) TExport the raw coded values or labels for the options of multiple choice fields.
rawOrLabelHeaders_ : str (report, record) TExport the variable/field names (raw) or the field labels (label).
exportCheckboxLabel_ : str Specifies the format of checkbox field values specifically when exporting the data as labels (i.e., when rawOrLabel=label).
returnFormat_ : str Format to return errors. Default is json.
Returns:
log : pandas.core.frame.DataFrame or None

Pandas dataframe of each download request.

content : pandas.core.frame.DataFrame or None

Pandas dataframe of all data downloaded.

start, end : str

Timestamp (ISO format) and name of most recent (end) and first (start) file created in folder.

now : str

Current timestamp in ISO format.

classmethod SFTP(source, destination, hostname, username, password, **kwargs)[source]

Connect to a remote server using a Secure File Transfer Protocol (SFTP).

Parameters:
source : str

The directory path to retrieve paticipant data.

destination : str

The directory path to save paticipant data.

hostname : str

SFTP hostname.

username : str

SFTP username.

password : str

SFTP password.

**kwargs : str or None, optional

Additional properties, relevent for specific content types. Here’s a list of available properties:

Property Description
filetype : :str or None Filetype to download. Default is csv.
Returns:
log : pandas.core.frame.DataFrame or None

Pandas dataframe of each download request.

content : pandas.core.frame.DataFrame or None

Pandas dataframe of all files downloaded.

start, end : str

Timestamp (ISO format) and name of most recent (end) and first (start) file created in folder.

now : str

Current timestamp in ISO format.

Examples

>>> name='r33'; source='/home/utweb/utw1211/public_html/r33'; d='/Users/mdl/Desktop/r33/'; un='utw1211'; pwd='43#!9amZ?K$'
>>> log, start, end, now = download.SFTP(source=s, destination=d, hostname=hostname, username=un, password=pwd)
classmethod box(source, destination, server, username, password)[source]

Connect to Box cloud cloud storage service, using File Transfer Protocol over SSL (FTPS).

Parameters:
source : str

The remoate path on box to retrieve data.

destination : str

The local path to download data.

server : str

Name of box server.

username : str

Box account email address.

password : str

Box account password.

Notes