Change the Extension
Imagine working in a data analytics team where you receive tons of data as text files. Your job is to convert these text files to CSV format for easier data manipulation using Python. Using the
pathlib
module, your task is to write a script that takes a text file as input and changes its extension from .txt
to .csv
.The first line of the input contains the full path of the text file that needs to be converted. The path includes the directory and the filename with the extension.
The program should print the full path of the file after the extension has been changed to
.csv
.Input | Output |
data/file1.txt | data/file1.csv |
Note: The program should only change the file's extension and not actually convert the content of the text file into CSV format. The task of converting the content of the text file into CSV format goes beyond the scope of this exercise.
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB