Editor 在大型文本文件中插入数字序列

Editor 在大型文本文件中插入数字序列,editor,sequence,text-editor,large-files,ultraedit,Editor,Sequence,Text Editor,Large Files,Ultraedit,我需要创建以下格式的文件: item0000001 item0000002 item0000003 item0000004 item0000005 我是用UltraEdit做的,它的列模式包括插入编号(开始+增量包括前导零) 不幸的是,UltraEdit炸弹超过了100万行 有人知道有一个文件容量大的文本编辑器有类似的操作吗?BaltoStar没有写下使用了哪个版本的UltraEdit,以及他是如何创建文件的 然而,这里有一个UltraEdit脚本,它可以用来创建一个文件,其中的行包含一个递增

我需要创建以下格式的文件:

item0000001
item0000002
item0000003
item0000004
item0000005
我是用UltraEdit做的,它的列模式包括插入编号(开始+增量包括前导零)

不幸的是,UltraEdit炸弹超过了100万行


有人知道有一个文件容量大的文本编辑器有类似的操作吗?

BaltoStar没有写下使用了哪个版本的UltraEdit,以及他是如何创建文件的

然而,这里有一个UltraEdit脚本,它可以用来创建一个文件,其中的行包含一个递增的数字,前导的零与最后一个数字一致

要在UltraEdit v14.20或UEStudio v9.00或任何更高版本中使用该脚本,请复制脚本的代码块,并将其粘贴到UltraEdit/UEStudio中带有DOS行终止的新ASCII文件中。例如,将文件另存为CreateLinesWithIncrementingNumber.js到您首选的UE/UES脚本目录中

现在,通过单击菜单脚本中的菜单项运行活动脚本来运行脚本

脚本会提示用户输入递增数字的第一个和最后一个值,以及递增数字的左侧和右侧的字符串(也可以是空字符串)

然后向后倾,看看脚本是如何将数字递增的行以块的形式写入新文件的。我使用这个UltraEdit脚本在几秒钟内创建了一个超过150 MB的文件,其数字从0递增到5.000.000

if (typeof(UltraEdit.clipboardContent) == "string")
{
   // Write in blocks of not more than 4 MB into the file. Do not increase
   // this value too much as during the script execution much more free
   // RAM in a continous block is necessary than the value used here for
   // joining the lines in user clipboard 9. A too large value results
   // in a memory exception during script execution and the user of the
   // script also does not see for several seconds what is going on.
   var nBlockSize = 4194304;

   // Create a new file and make sure it uses DOS/Windows line terminations
   // independent on the user configuration for line endings of new files.
   UltraEdit.newFile();
   UltraEdit.activeDocument.unixMacToDos();
   var sLineTerm = "\r\n";    // Type of line termination is DOS/Windows.

   // Ask user of script for the first value to write into the file.
   do
   {
      var nFirstNumber = UltraEdit.getValue("Please enter first value of incrementing number:",1);
      if (nFirstNumber < 0)
      {
         UltraEdit.messageBox("Sorry, but first value cannot be negative.");
      }
   }
   while (nFirstNumber < 0);

   // Ask user of script for the last value to write into the file.
   do
   {
      var nLastNumber = UltraEdit.getValue("Please enter last value of incrementing number:",1);
      if (nFirstNumber >= nLastNumber)
      {
         UltraEdit.messageBox("Sorry, but last value must be greater than "+nFirstNumber.toString(10)+".");
      }
   }
   while (nFirstNumber >= nLastNumber);

   var sBeforeNumber = UltraEdit.getString("Please enter string left of the incrementing number:",1);
   var sAfterNumber = UltraEdit.getString("Please enter string right of the incrementing number:",1);

   // http://stackoverflow.com/questions/16378849/ultraedit-how-do-i-pad-out-a-string-with-leading-blanks
   // Convert the highest number to a decimal string and get a copy
   // of this string with every character replaced by character '0'.
   // With last number being 39428 the created string is "00000".
   var sLeadingZeros = nLastNumber.toString(10).replace(/./g,"0");

   // Instead of writing the string with the incrementing number line
   // by line to file which would be very slow and which would create
   // lots of undo records, the lines are collected first in an array of
   // strings whereby the number of strings in the array is determined
   // by value of variable nBlockSize. The lines in the array are
   // concatenated into user clipboard 9 and written as block to the
   // file using paste command. That is much faster and produces just
   // a few undo records even on very large files.
   UltraEdit.selectClipboard(9);
   UltraEdit.clearClipboard();

   // Calculate number of lines per block which depends on the
   // lengths of the 4 strings which build a line in the file.
   var nLineLength = sBeforeNumber.length + sLeadingZeros.length +
                     sAfterNumber.length + sLineTerm.length;
   var nRemainder = nBlockSize % nLineLength;
   var nLinesPerBlock = (nBlockSize - nRemainder) / nLineLength;

   var asLines = [];
   var nCurrentNumber = nFirstNumber;

   while (nLastNumber >= nCurrentNumber)
   {
      // Convert integer number to decimal string.
      var sNumber = nCurrentNumber.toString(10);
      // Has the decimal string of the current number less
      // characters than the decimal string of the last number?
      if (sNumber.length < sLeadingZeros.length)
      {
         // Build decimal string new with X zeros from the alignment string
         // and concatenate this leading zero string with the number string.
         sNumber = sLeadingZeros.substr(0,sLeadingZeros.length-sNumber.length) + sNumber;
      }
      asLines.push(sBeforeNumber + sNumber + sAfterNumber);
      if (asLines.length >= nLinesPerBlock)
      {
         asLines.push(""); // Results in a line termination at block end.
         UltraEdit.clipboardContent = asLines.join(sLineTerm);
         UltraEdit.activeDocument.paste();
         UltraEdit.clearClipboard();
         asLines = [];
      }
      nCurrentNumber++;
   }
   // Output also the last block.
   if (asLines.length)
   {
      asLines.push("");
      UltraEdit.clipboardContent = asLines.join(sLineTerm);
      UltraEdit.activeDocument.paste();
      UltraEdit.clearClipboard();
   }
   // Reselect the system clipboard and move caret to top of new file.
   UltraEdit.selectClipboard(0);
   UltraEdit.activeDocument.top();
}
else if(UltraEdit.messageBox)
{
   UltraEdit.messageBox("Sorry, but you need a newer version of UltraEdit/UEStudio for this script.");
}
else
{
   UltraEdit.newFile();
   UltraEdit.activeDocument.write("Sorry, but you need a newer version of UltraEdit/UEStudio for this script.");
}
if(typeof(UltraEdit.clipboardContent)=“字符串”)
{
//将不超过4 MB的块写入文件。不要增加
//此值太大,因为在脚本执行期间更自由
//连续块中的RAM比此处用于
//连接用户剪贴板9中的行。结果值太大
//在脚本执行期间发生内存异常,并且
//脚本在几秒钟内也看不到正在发生的事情。
变量nBlockSize=4194304;
//创建一个新文件并确保它使用DOS/Windows行终止
//独立于新文件行尾的用户配置。
UltraEdit.newFile();
UltraEdit.activeDocument.UnixActodos();
var sLineTerm=“\r\n”;//行终止的类型是DOS/Windows。
//要求脚本用户输入要写入文件的第一个值。
做
{
var nFirstNumber=UltraEdit.getValue(“请输入递增数字的第一个值:”,1);
如果(nFirstNumber<0)
{
messageBox(“对不起,第一个值不能为负数。”);
}
}
而(nFirstNumber<0);
//向脚本用户询问要写入文件的最后一个值。
做
{
var nLastNumber=UltraEdit.getValue(“请输入递增数字的最后一个值:”,1);
如果(nFirstNumber>=nLastNumber)
{
messageBox(“抱歉,但最后一个值必须大于”+nFirstNumber.toString(10)+”);
}
}
而(nFirstNumber>=nLastNumber);
var sBeforeNumber=UltraEdit.getString(“请输入递增数字左边的字符串:”,1);
var sAfterNumber=UltraEdit.getString(“请在递增数字的右边输入字符串:”,1);
// http://stackoverflow.com/questions/16378849/ultraedit-how-do-i-pad-out-a-string-with-leading-blanks
//将最高数字转换为十进制字符串并获取副本
//将此字符串的每个字符替换为字符“0”。
//最后一个数字为39428,创建的字符串为“00000”。
var sLeadingZeros=nLastNumber.toString(10)。替换(//g,“0”);
//而不是用递增的数字行写入字符串
//通过行到文件,这将是非常缓慢的,这将创建
//许多撤销记录,行首先在一个数组中收集
//确定数组中字符串数的字符串
//根据变量nBlockSize的值。数组中的行为
//连接到用户剪贴板9并作为块写入
//文件使用粘贴命令。这是快得多,只产生
//即使在非常大的文件上也有一些撤消记录。
选择剪贴板(9);
UltraEdit.clearClipboard();
//计算每个块的行数,这取决于
//在文件中生成一行的4个字符串的长度。
var nLineLength=sBeforeNumber.length+sLeadingZeros.length+
sAfterNumber.length+sLineTerm.length;
var nMainder=nBlockSize%nLineLength;
变量nLinesPerBlock=(nBlockSize-nMainder)/nLineLength;
var asLines=[];
var nCurrentNumber=nFirstNumber;
while(nLastNumber>=nCurrentNumber)
{
//将整数转换为十进制字符串。
var sNumber=nccurrentnumber.toString(10);
//当前数字的十进制字符串小于
//大于最后一个数字的十进制字符串的字符数?
if(sNumber.length=nLinesPerBlock)
{
asLines.push(“”;//导致块端的行终止。
UltraEdit.clipboardContent=asLines.join(sLineTerm);
UltraEdit.activeDocument.paste();
UltraEdit.clearClipboard();
asline=[];
}
nCurrentNumber++;
}
//输出最后一个块。
if(asLines.length)
{
asline.push(“”);
UltraEdit.clipboardContent=asLines.join(sLineTerm);
UltraEdit.activeDocument.paste();
UltraEdit.clearClipboard();
}
//重新选择系统剪贴板并将插入符号移动到新文件的顶部。
UltraEdit.selectClipboa