我目前有一个这种格式的分隔文件(2 列选项卡“\t”分隔)和“;” 分隔列中的所有元素)。
User\tDate
Alice Cooper;John Smith\t07/11/2019
Alice Cooper\t23/11/2018
Alice Cooper\t21/11/2018
Alice Cooper\t26/11/2018
Alice Cooper\t26/11/2018
Alice Cooper;John Smith\t09/12/2018
Alice Cooper;John Smith\t09/12/2018
Alice Cooper;John Smith\t04/12/2018
Alice Cooper\t07/12/2018
Alice Cooper\t07/12/2018
我想对优化宏(最好是 javascript)有任何想法,以创建以下 OUTPUT 文件:
User\tEarliest\tLatest\tDates_with_Most_Occurences\tMost_Occurence_Number
Alice Cooper\t21/11/2018\t07/11/2019\t26/11/2018;07/12/2018\t2
John Smith\t04/12/2018\t07/11/2019\t09/12/2018\t1
所以中间步骤(我目前正在手动执行,但想转入宏):
第 1 步:分离列 1 中的名称元素
(给出这样的东西):
User\tDate
Alice Cooper\t07/11/2019
John Smith\t07/11/2019
Alice Cooper\t23/11/2018
Alice Cooper\t21/11/2018
Alice Cooper\t26/11/2018
Alice Cooper\t26/11/2018
Alice Cooper\t09/12/2018
John Smith\t09/12/2018
Alice Cooper\t09/12/2018
John Smith\t09/12/2018
Alice Cooper\t04/12/2018
John Smith\t04/12/2018
Alice Cooper\t07/12/2018
Alice Cooper\t07/12/2018
第 2 步:对 Col1 AZ 和 Col 2 最旧到最新进行排序。现在基于 Column 1 组合 Column 2 元素(给出类似的内容):
User\tDate
Alice Cooper\t21/11/2018;23/11/2018;26/11/2018;26/11/2018;04/12/2018;07/12/2018;07/12/2018;09/12/2018;09/12/2018;07/11/2019;
John Smith\t04/12/2018;09/12/2018;09/12/2018;07/11/2019;
第 3 步:现在在 Col2 中为每一行获取日期信息并创建这 4 个新列:EarliestDate、LatestDate、Dates_with_Most_Occurences、Most_Occurence_Number(给出类似的内容):
User\tDate
Alice Cooper\t21/11/2018;23/11/2018;26/11/2018;26/11/2018;04/12/2018;07/12/2018;07/12/2018;09/12/2018;09/12/2018;07/11/2019;
John Smith\t04/12/2018;09/12/2018;09/12/2018;07/11/2019;
第 4 步:删除 Col2(日期):给出最终输出:
User\tEarliestDate\tLatestDate\tDates_with_Most_Occurences\tMost_Occurence_Number
Alice Cooper\t21/11/2018\t07/11/2019\t26/11/2018;07/12/2018\t2
John Smith\t04/12/2018\t07/11/2019\t09/12/2018\t1
我只需要宏来创建最终输出,中间(上面的步骤 1、2、3)只是显示了我正在尝试做的事情的逻辑。真正的源文件将有数千行,所以如果这可以被 EmEditor 以任何方式优化,那就太棒了。