在分隔符处拆分并添加到新行

时间:2015-04-25 03:28:41

标签: excel excel-vba vba

我在Excel中有以下数据:

current

并希望得到类似下面的内容: proposed

有相当多的数据需要操作,所以我寻求最有效的方法来实现这一点,实质上它会涉及:

  • Region栏中搜索-
  • 如果找到,请抓取从-开始到-的下一个实例或end of cell
  • 的数据
  • 将数据复制到新行并附带扩展数据(根据第二个屏幕截图)
  • 循环

如果需要进一步的信息,请告诉我,并提前感谢

以下原始数据:

Current:
State   Region Type Frequency   Region  Time    Selected Medians and Averages   Value
New South Wales Statistical Area Level 2    Annual  Eden    2011    Median age of persons   47
New South Wales Statistical Area Level 2    Annual  Eurobodalla Hinterland  2011    Median age of persons   48
New South Wales Statistical Area Level 2    Annual  Merimbula - Tura Beach - Moss Beach 2011    Median age of persons   51
New South Wales Statistical Area Level 2    Annual  Moruya - Tuross Head    2011    Median age of persons   50

Proposed:
State   Region Type Frequency   Region  Time    Selected Medians and Averages   Value
New South Wales Statistical Area Level 2    Annual  Eden    2011    Median age of persons   47
New South Wales Statistical Area Level 2    Annual  Eurobodalla Hinterland  2011    Median age of persons   48
New South Wales Statistical Area Level 2    Annual  Merimbula   2011    Median age of persons   51
New South Wales Statistical Area Level 2    Annual  Tura Beach  2011    Median age of persons   51
New South Wales Statistical Area Level 2    Annual  Moss Beach  2011    Median age of persons   51
New South Wales Statistical Area Level 2    Annual  Moruya  2011    Median age of persons   50
New South Wales Statistical Area Level 2    Annual  Tuross Head 2011    Median age of persons   50

1 个答案:

答案 0 :(得分:2)

只有活动工作表上的当前数据和A1中的状态,请运行此宏。

Configuration config = HBaseConfiguration.create();
Job job = new Job(config, "ExampleRead");
job.setJarByClass(MyReadJob.class);     // class that contains mapper

Scan scan = new Scan();
scan.setCaching(500);        // 1 is the default in Scan, which will be bad for MapReduce jobs
scan.setCacheBlocks(false);  // don't set to true for MR jobs
// set other scan attrs
...

TableMapReduceUtil.initTableMapperJob(
   tableName,        // input HBase table name
   scan,             // Scan instance to control CF and attribute selection
   MyMapper.class,   // mapper
   null,             // mapper output key
   null,             // mapper output value
   job);
job.setOutputFormatClass(NullOutputFormat.class);   // because we aren't emitting anything from mapper

boolean b = job.waitForCompletion(true);
if (!b) {
    throw new IOException("error with job!");
}

建议的结果应填充在 Current 下方,与此类似。

Split array into multiple rows

相关问题