Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Opening CSV file from SFTP server not working

So after two days of scavenging the internet I have not found anything to help solve my issue. Any help or recommendations would be appreciated.

What I'm trying to do: There is an SFTP server that has a .csv file on it that I need to read. Downloading the csv and reading it is not an option as I'm developing a website.

I am currently using paramiko to access the server. It connects successfully. I use the following line of code to open the csv

 file ='fixed.csv')
The problems:
1) when I try to use pandas read_csv, it only displays the first row of elements.

Please note this also happens if I open the csv file from my local computer and not the SFTP. So I am assuming I am just using this wrong.

 csv = pandas.read_csv(file)
    for line in csv:
2) I also tried using the built in csv library. The problem here is that it will not open the file, and I get an error: "TypeError: expected str, bytes or os.PathLike object, not SFTPFile"

Please note that if I open the csv locally using this method, it works perfectly fine. So I am assuming the problem has something to do with the filetype.

with open(file) as csvfile:
        spamreader = csv.reader(csvfile)
        for line in spamreader:
I am at my wits end and have no idea how to proceed. Please let me know if I can provide additional information, thank you! Any help would be greatly appreciated.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python File to EXE Not working. MianDoesCoding 9 330 Jun-09-2020, 08:21 AM
Last Post: MianDoesCoding
  File Opening Hitso 10 400 Jun-05-2020, 10:35 AM
Last Post: DeaD_EyE
  Test a file for a string without opening it? tester_V 2 193 Jun-03-2020, 06:40 PM
Last Post: tester_V
  How to assess elapsed time to execute a .exe file or opening a desktop application? Sudershan 2 364 Apr-18-2020, 01:40 PM
Last Post: buran
  Opening a file amitsinbox 6 360 Apr-13-2020, 11:54 AM
Last Post: amitsinbox
  How To Find an Opening and Closing String, Copying Open/Close/Contents to New File davidshq 1 321 Mar-03-2020, 04:47 AM
Last Post: davidshq
  Internal Server Error 500 on creating .py file patrickluethi 0 414 Aug-02-2019, 01:57 PM
Last Post: patrickluethi
  Error -3 when opening matlab file in python python_newbie09 0 442 Aug-02-2019, 11:51 AM
Last Post: python_newbie09
  python script file not opening in IDLE editor srm 2 843 Jun-23-2019, 08:45 AM
Last Post: Larz60+
  Working with LibreOffice file FASB 0 474 Jun-13-2019, 01:23 PM
Last Post: FASB

Forum Jump:

Users browsing this thread: 1 Guest(s)