Ok, since it is a file with data that are column aligned, there are really a lot you can do with straight forward column mode operations. See
power tip for column mode...Ok, but you asked for a script, so here goes

- but beware "...huge file..." and scripts sometimes = slow.
You didn't use [code ] [/code ] tags

to wrap round your example, but from "view source" I was able to reconstruct it:
- Code: Select all
200701277 2007060105191000009781400052448 380J00 1- 1350- 1350-USD 04 000001ZG2 R421 0000000000000010097863321
200701273 2007060110356800009780307275004 29255M 9 3145 3145 USD 01 000001ZL2 R421 0000000000000020097863403
Then run this (hopefully self explaining) script demonstrating the powerful column mode and som simple regex:
- Code: Select all
UltraEdit.ueReOn(); /* UE style regex engine */
UltraEdit.selectClipboard(9); /* use clipboard 9 */
UltraEdit.columnModeOn(); /* switch to column mode */
wDoc = UltraEdit.document[getActiveDocumentIndex()]; /* I like shortcuts ;-) */
wDoc.gotoLine(1,54); /* goto start of the area we are going to reformat */
wDoc.columnCut(55); /* cut the whole area to clipboard - 55 chars wide */
/* ------------- */
UltraEdit.newFile(); /* open a blank file */
tempDoc = UltraEdit.document[getActiveDocumentIndex()]; /* I like shortcuts ;-) */
tempDoc.paste();
tempDoc.findReplace.replaceAll=true;
tempDoc.findReplace.regExp=true;
tempDoc.findReplace.replace("^([0-9]+^)^([ -]^)","^2^1"); /* move sign in front of number */
tempDoc.top();
tempDoc.selectToBottom(); /* select reformatted text */
tempDoc.copy();
UltraEdit.closeFile(tempDoc.path,2); /* we are finished with this temporary file */
/* ------------- */
wDoc.paste(); /* and we're back */
UltraEdit.clearClipboard(); /* clean up */
UltraEdit.selectClipboard(0); /* switch to primary clipboard */
wDoc.gotoLine(1,69); /* 1st column to amputate to make room for decimal separator */
wDoc.columnDelete(1);
wDoc.gotoLine(1,86); /* 1st column for decimal separator */
wDoc.columnInsert(".");
wDoc.gotoLine(1,89); /* 2nd column to amputate to make room for decimal separator */
wDoc.columnDelete(1);
wDoc.gotoLine(1,106); /* 1st column for decimal separator */
wDoc.columnInsert(".");
/* ------------- */
/* Find the tab index of the active document */
function getActiveDocumentIndex() {
var tabindex = -1; /* start value */
for (i = 0; i < UltraEdit.document.length; i++)
{
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
return tabindex;
}
to produce this result:
- Code: Select all
200701277 2007060105191000009781400052448 380J00 -1 -13.50 -13.50USD 04 000001ZG2 R421 0000000000000010097863321
200701273 2007060110356800009780307275004 29255M 9 31.45 31.45USD 01 000001ZL2 R421 0000000000000020097863403