|
Answer» Hello,
I have a FILE and would like to count in this file the COMMAS in each line. If there is less than 20 commas, I would like to insert the difference at the end of each line.
Thanx in advance.i am no GOOD at batch for such tasks. So here's one done in Python (similarly can be done in other scripting languages)
Code: [Select]for lines in open("thefile.txt"): lines = lines.strip() #GET rid of NEWLINES. commacount = lines.count(',') # count how many commas if commacount < 20: print lines + "," * (20-commacount) # print the remaining commas just a few lines of code and im done.
|