java - 我想将 iphone 名称及其价格存储在 excel 表中。对于相同的 iphone 名称在一张 excel 表中疼痛
问题描述
转到 Flipkart 搜索 iphone 以获取相同的 i 电话名称为另一个 iphone 名称创建一个 excel 表创建另一个 excel 表。
代码如下所示:
public static void main(String[] args) {
Set<String> uniquename = new HashSet<String>();
ArrayList<String[]> data1 = new ArrayList<String[]>();
Map<String,List<String[]> > hashmap = new HashMap<String,List<String[]> >();
data1.add( new String[] {"Apple iPhone 8 Plus (Space Grey, 64 GB)","56000"});
data1.add(new String[] {"Apple iPhone 6 (Grey, 128 GB)","47000"});
data1.add(new String[] {"Apple iPhone XS (Space Grey, 512 GB)","28000"});
data1.add(new String[] {"Apple iPhone XS (Space Grey, 512 GB)","29000"});
data1.add(new String[] {"Apple iPhone 7 Plus (Gold, 128 GB)","19000"});
data1.add(new String[] {"Apple iPhone 7 Plus (Gold, 128 GB)","18000"});
for(String[] data:data1) {
uniquename.add(data[0].replace("(", "#").split("#")[0] );
}
System.out.println(uniquename);
System.out.println(uniquename.size());
System.out.println(data1.size());
for(String name : uniquename) {
List<String[]> temp =new ArrayList<String[]>();
for(String[] d : data1) {
if(name==d[0].substring(0, 19)) {
temp.add(d);
}
hashmap.put(name, temp);
}
}
Set keys = hashmap.keySet();
System.out.println("All keys are: " + keys);
List<String[]> value = hashmap.get(keys);
for(String[] val : value) {
System.out.println(value);
}
}
提前谢谢。
解决方案
推荐阅读
- c# - 为什么c#不能从非托管dll中获取正确的参数值
- drop-down-menu - Kivy 在更改后动态更新 MDDropDownMenu 项目
- c# - 我可以将基类类型作为泛型参数传递给接口吗
- statistics - 面板向量纠错模型(VECM)的估计方法
- php - 制作模块时如何在 Silverstripe 中添加导航项?
- javascript - 关于使用 JavaScript 接收流的更一般的问题
- java - 循环 SQL 选择
- sql - 加入不返回某些行
- python - Pandas - 将列表的值连接到数据框中的单个列中
- java - Spring Security 中没有为 id "null" 映射 PasswordEncoder