Ever need to convert lines in vertical format to a CSV formatted format or a format that's like a Python list?
Paste command in Linux can easily do this.
Example data:
server01_local
server02_local
server03_local
server04_local
server05_local
server01_cluster
server02_cluster
server03_cluster
server04_cluster
server05_cluster
Convert to CSV format or a Python list format with commas as delimiters.
Here's the command that does the trick:
paste -sd ',' file1.txt > file2.txt (see image below for the command)
That's it, that's the magic; the command above will convert the file to a CSV formatted format.
Then it can be feed to a Python program for further processing or automation.
Example image output:
Till next time. Keep exploring. Work Smart and use the technology to make your life easier.
Put God first always. Everything else will fall into place and Trust His Timing.
As they said, all good things come to those who patiently wait. Keep the faith and don't falter.
Fiat Voluntas Tua | Catholic Prayers & Quotes


Comments
Post a Comment