'saving csv according to the name of file in python automatically

i don't want to save the csv files manually.Is there a code that could be done automatically?First i load the file1,convert it to dataframe and do some processes that doesn't have any significant about my question. Here's the file:

file1="C:/Users/ozzgu/OneDrive/Desktop/ml articles/model/datasets/RC101.txt"
rc1=pd.read_csv(file1,sep="\s+")

After processing,i need to save txt file just like below.

vehicle1.to_csv("vehicle1_KMEANS3V_RC101.txt")

If I load file1=RC102.txt,does it have a way to save automatically "vehicle_KMEANS3V_RC102.txt".Thanks



Sources

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

Source: Stack Overflow

Solution Source