Prefix, Replace duplicate text in a line
Posted: 06 Nov 2010 00:37
Hi,
I'm looking to perform multiple operations on a text file. At a minimum, I want to know how to replace duplicate text within a row. Below is source.txt file contents.
"117981" "YOC AG"<tab>
"118127" "118127"<tab>
"702337" "Carlson Marketing Worldwide, I"<tab>
Ideally, the output file target.txt will:
1.) Replace the single space between column one and two.
2.) Remove the trailing tab character in each row.
3.) If the second column is a duplicate of the first column, it should be replace with empty double quotes.
4.) Add a prefix text "Col1", text to each row.
"Col1","117981","YOC AG"
"Col1","118127",""
"Col1","702337","Carlson Marketing Worldwide, I"
Looking for a purely dos batch based solution for this.
Thanks!
I'm looking to perform multiple operations on a text file. At a minimum, I want to know how to replace duplicate text within a row. Below is source.txt file contents.
"117981" "YOC AG"<tab>
"118127" "118127"<tab>
"702337" "Carlson Marketing Worldwide, I"<tab>
Ideally, the output file target.txt will:
1.) Replace the single space between column one and two.
2.) Remove the trailing tab character in each row.
3.) If the second column is a duplicate of the first column, it should be replace with empty double quotes.
4.) Add a prefix text "Col1", text to each row.
"Col1","117981","YOC AG"
"Col1","118127",""
"Col1","702337","Carlson Marketing Worldwide, I"
Looking for a purely dos batch based solution for this.
Thanks!