Create A New File Name After Decoding An Input Value
In this post I have asked how to select files in a directory by using a number as index. Now I would like to save this file in an automatic way, without adding manually the name. F
Solution 1:
This one solution there can be many. When you read the dataframe, save the name of the file as the name of the index and later you can use this variable in case query
no longer is available:
df = pd.read_csv(files[int(query)])
df.index.name = files[int(query)]
# Do other stuff
csv_name = df.index.name.split('.')[0] + '_test.txt'
df.to_csv(csv_name)
Post a Comment for "Create A New File Name After Decoding An Input Value"