Skip to main content

The sftp connector supports reading and writing CSV, Excel and JSON files to & from an SFTP server.

Tabset

Read​

Recipe​

read:
- sftp:
host: sftp.domain
user: user
password: password
file: file.csv

# Optional
columns: # Only import select columns
- column1
- column2
sheet_name: Sheet1 # Used for Excel files
nrows: 10 # Limit the number of rows
orient: records # Used for JSON files - defines the structure

Function​

from wrangles.connectors import sftp
df = sftp.read(
host='sftp.domain',
user='user',
password='password',
file='myfile.csv'
)

Parameters​

The SFTP connector also supports the same optional parameters as the file connector. See the file connector for more details.

ParameterRequiredData TypeNotes
host✓strHostname or IP address of the server.
user✓strThe user to connect to the server as.
password✓strPassword for the specified user.
file✓strFile name (and path, if required) to read from the server.
order_bystrUses SQL syntax to sort the input.
ifstrA condition that will determine whether the action runs or not as a whole.

Write​

Recipe​

# Write specific fields
write:
- sftp:
host: sftp.domain
user: user
password: password
name: file.csv

# Optional
columns:
- column1
- column2

Function​

from wrangles.connectors import sftp
sftp.write(
df,
host='sftp.domain',
user='user',
password='password',
file='myfile.csv'
)

Parameters​

The SFTP connector also supports the same optional parameters as the file connector. See the file connector for more details.

ParameterRequiredData TypeNotes
df✓DataFrameFunction only. DataFrame of contents to write to the file.
host✓strHostname or IP address of the server.
user✓strThe user to connect to the server as.
password✓strPassword for the specified user.
file✓strFile name (and path, if required) to write to the server.
order_bystrUses SQL syntax to sort the output.
ifstrA condition that will determine whether the action runs or not as a whole.