1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Pandas .to_csv() gives "No engine for filetype: 'csv'"

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    Basically, the title. The pd.Dataframe.to_csv() method works fine on my machine outside of the app code, but if I try to run it in a pyqt5 gui, I get the following error: No engine for filetype: 'csv'. Below is the function that causes the error. Note: if the user gives an .xlsx file, the .to_excel() function works fine. The file name the function uses is passed through a QFileDialog object. Here is the function causing the problem.

    def writeToFile(self, file, rows):

    try:

    new_df = pd.DataFrame(rows.items(), columns = ['Company Name', 'File Number'] )

    if self.stack.currentIndex() == 0:

    if file[-4:] == '.csv':

    df = pd.read_csv(file)
    new_df = pd.concat([df, new_df])

    else:

    df = pd.read_excel(file)
    new_df = pd.concat([df, new_df])

    if file[-4] == '.csv':

    new_df.to_csv(file, index = False, compression = None)

    else:

    new_df.to_excel(file)

    if self.flag_uids == []:

    return "All emails were written to a file"

    else:
    s = "All emails possible were written to a file. There were " + str(len(self.flag_uids)) + " messages unable to be interpreted"
    return s

    except Exception as e:

    return e

    Continue reading...

Compartilhe esta Página