#17872
no1
Participant

Thank you, Yutaka.

My files are many and large (thousands of lines or even more per file, about 200 columns per line, the column widths variable). So I’m afraid operation macros might not fit my case.

I wrote a script macro with the help of others. Could you (or anyone) take a look to see if there’s anything to be amended in it? And see if the regular expressions could be optimized. (After I tested a few, I think the shorter, the faster.)
The files are large. So the efficiency and stability should be considered.

Currently the only but fatal problem is:
The regular expression ^ would match the position after this character:
U+0085 <control> : NEXT LINE
How to resolve it?

if(document.Encoding != eeEncodingBinary) {
	alert("TSV ASCII\n\nUse this macro in Binary (ASCII View) mode only!");
	Quit();
};

var str = "8,50,30,30,30,50,50,50,50,30,15,8,1,6,25,25,55,55,55,55,12,30,11,3,30,24,55,55,55,55,12,30,11,3,30,55,55,55,55,3,30,30,10,3,1,1,1,30,1,10,4,1,6,3,8,10,6,30,10,6,6,1,1,1,1,1,1,1,1,30,30,30,1,8,8,8,8,8,8,8,8,8,8,8,8,8,1,10,3,30,4,5,7,7,4,3,30,5,19,19,19,19,20,7,8,9,19,19,8,10,30,50,5,35,3,30,3,30,4,30,4,30,25,4,50,3,30,3,30,30,40,30,40,30,40,30,40,30,40,30,40,6,8,50,50,50,5,25,6,6,70,20,1,5,5,3,10,30,25,5,30,8,3,3,8,8,3,5,3,8,8,6,8,2,2,8,12,3,2,8,1,5,5,1";
str = prompt("[TSV ASCII]    Enter width of each column:    (e.g. 10,5,1,7)", str);
var arr = str.split(",");

Redraw = false;

var n = 0
for(var i = 0; i < arr.length - 1; i++) {
	n = n + parseInt(arr[i]);
	document.selection.Replace("^.{" + n + "}", "\\t", eeReplaceAll | eeFindReplaceRegExp);
	n = n + 1;

	//Monitor/Break:
	document.HighlightFind = false;
	Redraw = true;
	if(!confirm("Monitor/Break:\n\n" + i + " " + arr[i] + " " + n + " done.\n\nContinue?")) Quit();
	Redraw = false;
};

document.selection.Replace(" +\t", "\t", eeReplaceAll | eeFindReplaceRegExp);