I want ro read *.csv files with st.file_uploader that have different separators like “,” or “;”. Not mixed in one file, e.g. read a file today that has “,” as separator, then tomorrow one that has “;” as separator.
Normally I would use Sniffer
import csv import pandas def get_delimiter(file_path, bytes = 4096): sniffer = csv.Sniffer() data = open(file_path, "r").read(bytes) delimiter = sniffer.sniff(data).delimiter return delimiter delimiter = get_delimiter(file_path) pd.read_csv(file_path, sep=delimiter)
The sniffer is not working with st.file_uploader, because st.file_uploader reads the bytes to the RAM, there is no filepath that can be accessed.
I would like that it is automatically recognized which seperator the *.csv file has and that this information is passed to read_csv.