简体   繁体   English

我有以下数据集,我想根据重复次数将此数据更改为目标输出数据集

[英]I have below dataset and i want to change this data into target output datatset on the basis of number of repetitions

I have below dataset and i want to make repititions of my rows that number of times and assign index to them.我有以下数据集,我想对我的行进行重复次数并为它们分配索引。

Thanks in advance.提前致谢。 Every suggestion is appreciated :)每个建议表示赞赏:)

INPUT:输入:

Col1    col2    col3    repetition
101 test1   10      2
102 test2   20      1
103 test3   30      2
104 test4   40      1

OUTPUT:输出:

col1            col2           col3       index
101     test1       10      1
101     test1       10      2
102     test2       20      1
103     test3       30      1
103     test3       30      2
104     test4       40      1

Here is some java code that describes the algorithm to accomplish this:下面是一些 Java 代码,描述了实现此目的的算法:

 List<InputType> inputList = getInput(); List<OutputType> outputList = new ArrayList<>(); foreach(InputType input in inputList){ for(int index = 1; index <= input.repetition){ OutputType output = new OutputType(input.col1, input.col2, input.col3, index); outputList.add(output) } } System.out.println(outputList);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有两个列表,我想根据 groovy 或 java 中其他列表中的 id 过滤一个列表 - I have two list and i want to filter a list on the basis of id present in other list in groovy or java 我正在创建一个Android应用,我希望多个人可以访问相同的号码,并能够通过两个按钮更改该号码 - I am creating an android app and I want multiple people to have access to the same number and be able to change that number with two buttons 我想在Maven中更改目标文件夹的路径 - I want to change the path of my target folder in maven Java:我想获取输出流已将数据写入文件的行的行号 - Java : I want to get the line number of the line where output stream has written the data in a file 我有一个来自 SQL Server 存储过程的 ArrayList,我想将所有数据插入 SQLite 数据库。 请看我下面的代码 - I have an ArrayList coming from SQL Server stored procedure and I want to insert all the data to a SQLite database. Please look at my code below 我想调整输出 - I want to adjust the output 我有 2 个并发数据结构,我想以原子方式更新它们 - I have a 2 concurrent data structures and I want to update them atomically 我想将数字拆分为一个数字并将其更改为android中的二进制 - I want to split a number into single digit and change it into the binary in android 我想在jtable中计算数据,但出现错误[Java] - I want to calculate data in jtable but i have a error [Java] 我想根据 ZipCode 使用 NCDC(国家气候数据中心)气候数据 API 获取美国过去的最高和最低温度 - I want to fetch max and min past temperature of US on the basis of ZipCode using NCDC (National Climate Data Center)climate Data API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM