0

I am trying to get a user input and pass it into a read_sheet() function, but I am getting the error OSError: [Errno 22] Invalid argument: '"D:\July8\E45-ACK-2_20190709_011216.xlsx"'. I think the problem may be that the user input is seen by python as a sting, but I'm not sure.

I tried doing

import pandas as pd

def read_sheets(sheets):
    df = pd.read_excel(sheets), sheet_name="Brightfield Size")
    live_cells = df["Unnamed: 1"].drop([0,1,2])
    dead_cells= df["Unnamed :5"].drop([0,1,2])
    return live_cells , dead_cells

x = input("Copy and paste the complete file path:")
r = read_sheets(x)
print (r)

then I tried

import pandas as pd

def read_sheets(sheets):
    df = pd.read_excel(open(sheets, "r"), sheet_name="Brightfield Size")
    live_cells = df["Unnamed: 1"].drop([0,1,2])
    dead_cells= df["Unnamed :5"].drop([0,1,2])
    return live_cells , dead_cells

x = input("Copy and paste the complete file path:")
r = read_sheets(x)
print (r)

But it is still giving me the error:

OSError: [Errno 22] Invalid argument: '"D:\July8\E45-ACK-2_20190709_011216.xlsx"'

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
subjectx
  • 1
  • 1

0 Answers0