如何合并连续的行以反映来自同一记录的数据?

如何合并连续的行以反映来自同一记录的数据?

我希望有人可以在 Notepad++ 或 Excel/VBA 上提供帮助。

我有下面的数据(抱歉我无法附加文件)但如果将示例数据复制到 Notepad++ 中,它应该有 12 行数据。

假设我正在使用 Notepad++:

  • 第 4、5 和 6 行来自一条记录,但分布在多行之间。

  • 第7、8、9行是单独的记录。

  • 第 10、11 和 12 行来自一条记录,但分布在多行之间。

有人能帮忙吗,或者告诉我一种快速显示一行记录的方法,以便我可以分析数据?目前我冒着失去记录数据完整性的风险。

任何帮助将非常感激。

Finance,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Account_name,Serial Number,AcctNum,Created Date,Updated Date,Number of Digits,Measurement Units,Currency Free Descriptor,Size,Frequency,Return,Object Chargeable Size,Category Chargeable Size,logger(W),logger (NW),AMDX,AMDY,RAD Location Free Descriptor,RAD Outreader GISX,RAD Outreader GISY,RAD Outreader Location Free Descriptor,RAD Treatment,RAD Location Code,Combi RAD Flag,Vol,Remote Flag,Remote Type,Outreader ID,Outreader Protocol,Address – Free Descriptor,Address – Secondary Addressable Object,Address – Primary Addressable Object,Address - Address Line 1,Address - Address Line 2,Address - Address Line 3,Address - Address Line 4,Address - Address Line 5,Address - Postcode,Address - PAF Address Key 

Account_name,94T034862,9911637482NUM19,2014-11-19,,5,pounds,,15,B,100.00,15,15,0,0,535551.0,198661.0,"PANEL RHS OF COLUMN NR CHILLERCABS. BACK OF SHOP BEFORE BAKERY.
",82644.0,5186.0,"PANEL RHS OF COLUMN NR CHILLERCABS. BACK OF SHOP BEFORE BAKERY.
",TAX,I,0,30,0,,,,936065186,,,918,SWINGFORD RD,,MENFIELD,MIDDX,YYY XX1,
Account_name,94T034868,9911429278NUM17,2014-11-07,,5,pounds,,15,B,100.00,15,15,0,0,525425.0,178736.0,CELLAR.TEL.0171 9121401,82644.0,5186.0,CELLAR.TEL.0171 9121401,TAX,I,0,158,0,,,,216031935,,,147,SUPER DEN RD,,MONTY,,YYY 9XX2,
Account_name,94T034871,9910235259NUM13,2015-01-30,,5,pounds,,15,B,100.00,15,15,0,0,518053.0,174903.0,THIS SECTION OF UNION CT ISV IA ALLEY ON RHS OF NO15 SHEENR D (FEATHERSTONE LEIGH)..PROCEE D 30 MTRS ALONG ALLEY.THENUNDE R.ARCH.ON.RHS.TO SHOP T/AS'TEC HISM...MTR BELOW WASH BASIN R/ O PREMISES...,82644.0,5186.0,THIS SECTION OF UNION CT ISV IA ALLEY ON RHS OF NO15 SHEENR D (FEATHERSTONE LEIGH)..PROCEE D 30 MTRS ALONG ALLEY.THENUNDE R.ARCH.ON.RHS.TO SHOP T/AS'TEC HISM...MTR BELOW WASH BASIN R/ O PREMISES...,TAX,I,0,37,0,,,,17644552,,,167,UNION PARK,,BEDMOND,SUNVIL,YYY XX3,
Account_name,94T034887,9910508441NUM12,2014-10-24,,5,pounds,,15,B,100.00,15,15,0,0,540456.0,185014.0,CELLAR FRONT RIGHT,82644.0,5186.0,CELLAR FRONT RIGHT,TAX,I,0,105,0,,,,149388560,,,111 SHOP,GUNFERD RD,,PERL,,YYY XX4,
Account_name,94T034889,9910698216NUM14,2014-11-28,,5,pounds,,15,B,100.00,15,15,0,0,525594.0,178188.0,"IN STORES (SPIRITS) UNDER SHELF ACCESS AFTER 12NOON AS KEY TO SPIRIT STORE NOT AVAILABLE BEFORE 12NOON
",82644.0,5186.0,"IN STORES (SPIRITS) UNDER SHELF ACCESS AFTER 12NOON AS KEY TO SPIRIT STORE NOT AVAILABLE BEFORE 12NOON
",TAX,I,0,30,0,,,,64777361,,,286 SHOP,OLD COMPTON RD,,FETLING,,YYY XXW,

答案1

使用 Notepad++,这将替换所有不以“Account”一词结尾的换行符

  • Ctrl+H
  • 找什么:\R(?!Account)
  • 用。。。来代替:LEAVE EMPTY
  • 查看 相符
  • 查看 环绕
  • 查看 正则表达式
  • 取消选中 . matches newline
  • Replace all

解释:

\R              # any kind of linebreak (i.e. \r, \n, \r\n)
(?!Account)     # negative lookahead, make sure we haven't the word "Account" after 

屏幕截图(之前):

在此处输入图片描述

屏幕截图(之后):

在此处输入图片描述

相关内容