'Streamlit file uploader error in VCF file format

I want to read vcf file using streamlit file uploader. but i am getting TypeError: expected str, bytes or os.PathLike object, not UploadedFile

import io.
import os
import pandas as pd
import streamlit as st

ifile=st.file_uploader('choose a file')
if ifile is not None:

  def read_vcf(path):
      with open(ifile, 'r') as f:
          lines = [l for l in f if not l.startswith('##')]
      return pd.read_csv(
          io.StringIO(''.join(lines)),
          dtype={'#CHROM': str, 'POS': int, 'ID': str, 'REF': str, 'ALT': str,
                'QUAL': str, 'FILTER': str, 'INFO': str},
          sep='\t'
      ).rename(columns={'#CHROM': 'CHROM'})
  st.write(read_vcf(ifile))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source