I want to read vcf file using file uploader

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

ifile=st.file_uploader(‘sample.vcf’,type=‘vcf’)
if ifile:

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))

This code shows, TypeError: expected str, bytes or os.PathLike object, not UploadedFile

Hi @Manjeet_Yadav, welcome to the community! :wave: :partying_face:

I would suggest reading through the examples section of the st.file_uploader docs to understand how to read files into various formats:

e.g. To convert to a string based IO:
stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))