Notepad++ rows to columns, in groups

时间:2017-08-30 20:45:17

标签: datatables notepad++ transpose

I have found a ton of ways to transpose columns to text in Notepad++ and vice versa. However, where I'm struggling is that I have one column with several rows. I can't 'just' transpose these as the data winds up being in the wrong order.

Example:

devicesList

When I transpose this, I wind up with:

devicelist = (ListView) mView.findViewById(R.id.listDevicesDialog);

I need everything to remain in groups so I wind up with the following, noting that I also need a delimiter added:

private void pairedDevicesList(View dialogView)
{
    pairedDevices = myBluetooth.getBondedDevices();
    ArrayList list = new ArrayList();
    devicelist = (ListView) dialogView.findViewById(R.id.listDevicesDialog); 
...
}
// show the dialog for connected devices
private void showDialog()
{
    AlertDialog.Builder mBuilder = new AlertDialog.Builder(DeviceList.this);
    View mView = getLayoutInflater().inflate(R.layout.device_dialog, null);
    mBuilder.setView(mView);
    AlertDialog dialog = mBuilder.create();
    dialog.show();
    pairedDevicesList(mView);
}

As you can see with the company EnviroSolar Power, there is a space between "EnviroSolar" and "Power" and anything I've tried winds up removing the spaces that should remain in tact when transposing.

I appreciate ANY help you can offer! Thank you in advance!

2 个答案:

答案 0 :(得分:0)

假设你的行总是以整数开头(当然除了标题行),而且只有第一列包含整数,你可以用两次搜索替换( Ctrl + < KBD>ħ)。

请务必选择“正则表达式”搜索模式。

首先用管道替换所有换行符。这将暂时将所有内容放在一行。

找到:\n

替换为:|

下一步找到所有纯数字字段,并使它们从一行开始,以达到所需的结果。

找到:\|([0-9]+)\|

替换为:\n$1|

答案 1 :(得分:0)

如果您知道列数,实际上这里是5,您可以分两步完成:

<强>首先

  • 控制 + ħ
  • 找到:(?:[^\r\n]+\R){5}
  • 替换为:$0\n
  • 全部替换

<强>解释

(?:             : start non capture group
    [^\r\n]+    : 1 or more any character but line break
    \R          : any kind of line break
){5}            : group must occurs 5 times, 
                  here you can give the columns number of your choice

这将在5列之后添加换行符。

  • 检查正则表达式

<强>第二

  • 控制 + ħ
  • 找到:(\R)(?!\R)|(\R\R)
  • 替换为:(?1|:\n)
  • 全部替换

<强>解释

(\R)            : any kind of line break, in group 1
(?!\R)          : negative lookahead, make sure we have not another linebreak after
|               : OR
(\R\R)          : 2 line break, in group 2

<强>替换

(?1             : conditional replacement, is group 1 existing
  |             : yes ==> a pipe
 :\n            : no ==> linebreak
)               : end condition

这将通过管道替换单个换行符,并用单个换行符替换2个换行符

给定示例的结果:

RANK|COMPANY|GROWTH|REVENUE|INDUSTRY
1|Skillz|50,058.92%|$54.2m|Software
2|EnviroSolar Power|36,065.06%|$37.4m|Energy