I have written fast API to upload a file but in my new requirement, I have to create CLI to upload a file for that I am calling route function.
@app.post("/uploadfile/")
async def create_upload_file(file: Uploadfile =File(...));
pd.DataFrame = pd.read_csv(file.file)
return True
create_upload_file(file=UploadFile(input_file_path))
when i tried to read that file like : claims: pd.DataFrame = pd.read_csv(file.file) i am getting following error
No columns to parse from file
you can read the csv as following:
from io import BytesIO
df = pd.read_csv(BytesIO(file.file.read()))