• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / How to Read XLSX File from Remote Server Using Paramiko FTP and Pandas

How to Read XLSX File from Remote Server Using Paramiko FTP and Pandas

November 24, 2021 Leave a Comment

Many times, when working with files and remote servers, it would be helpful if we could use code to manipulate directories and files to make processes more efficient.

In many organizations, Microsoft Excel files store data for different processes, and from time to time, we need to update the data stored in these files.

Having to update these files manually can be a nightmare. Adding to that, if you are working with remote servers, there will most likely need to be some copying back and forth to your local computer.

With Python, we can write a program that does these manipulations for us, and save a lot of headache.

Using Paramiko and Pandas, we can easily read xlsx files from a remote server.

How to Read an XLSX File from a Remote Server Using Pandas, Paramiko and FTP

Below is the code that I use to read xlsx files from a remote server using Pandas and Paramiko.

First, we connect to the server. Then we just need to open the Excel file and read from it using the .read_excel() pandas function.

import io
import paramiko
import pandas as pd

#connect to remote server

host = "yourhost"
username = "yourusername"
password = "yourpassword"

con = paramiko.SSHClient()
con.load_system_host_keys()
ftp.set_missing_host_key_policy(paramiko.AutoAddPolicy())
con.connect(host, username, password)
ftp = con.open_sftp()

#read in existing xlsx file contents to dataframe

existing_xlsx = ftp.open("yourfilepath/existingfilename.xlsx")
df = pd.read_excel(existing_xlsx)

Hopefully, this post has helped you with automating a process using Python and manipulating Microsoft Excel files on your remote server.

Other Articles You'll Also Like:

  • 1.  Get Month Name from Date in Python
  • 2.  Remove Character from String in Python by Index
  • 3.  pandas DataFrame size – Get Number of Elements in DataFrame or Series
  • 4.  Find Last Occurrence in String of Character or Substring in Python
  • 5.  Get pandas Series First Element in Python
  • 6.  How to Iterate over Everything in Word Document using python-docx
  • 7.  Using Python to Count Items in List Matching Criteria
  • 8.  pandas head – Return First n Rows from DataFrame
  • 9.  How to Shutdown Computer with Python
  • 10.  Get Day of Year from Date in pandas DataFrame

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy

x