Markus Wiesinger
Markus Wiesinger

Reputation: 1

CSV File cannot creat: Bad File Descriptor

Failure: OSError: [Errno 9] Bad file descriptor

Python can not find the path!!

import pandas as pd
import csv

def read_csv_auto_header(file_path):
    # Öffnen der CSV-Datei und Lesen der Daten mit dem csv.reader
    # CSV-Datei in DataFrame lesen
    df = pd.read_csv(file_path, encoding='ISO-8859-1', sep=';')
    
    # Ersetzen von mehrstelligen Leerzeichen durch ein Leerzeichen
    df = df.replace('\s+', ' ', regex=True)
    df.to_csv(r'D:\Markus\00_Documents\20_Bildung\60_Self_Online_Study\60_Programmieren\Projekte\CreditKonto_analysing\neue_datei.csv',index=False,header=True)

   


# Beispielverwendung
file_path = 'Buchung.csv'  # Ersetze 'Buchung.csv' durch deinen Dateipfad zur CSV-Datei
read_csv_auto_header(file_path)

different coding of the path

How can I solve the issue?

Upvotes: -1

Views: 108

Answers (1)

  1. Double check that file path is correct or the file is existed in there.
  2. use absolute file path from local drive. example: C:\Users\Durjoy\OneDrive\Desktop\buchung.csv something like this.
  3. check the file permission wheather this file is readable or not. if it's not readable, change the permission.
  4. if file is open in somewhere else, close it and try again.

I hope your problem will be solved.

Upvotes: 0

Related Questions