用一个列的mutiple行解析CSV文件,并且是动态的
现在,从上图中,我想将数据从CSV/Excel解析为A 列表所有者。有人可以帮我如何做吗?
class Owner{
String name;
String address;
List<Vehicle> vehicle;
}
class Vehicle{
String number;
double price;
}
我知道我可以使用Apache POI来解析Excel和Apache Commons来解析CSV。我的主要困惑是如何继续阅读文件: 例如:从查看图像/文件,我可以知道Kumar有四辆车,但是如何将其翻译成代码:(在此处输入图像描述
输入: 姓名,地址,车辆,价格 Kumar,班加罗尔,KA01AA1234,900300, ,KA01AA1235,700300, ,,KA01AA1236,560300, ,,KA01AA1237,770300, Suresh,Mangalore,KA20AA1234,900300, ,,KA20AA1235,700300, ,,KA20AA1236,560300, Ramesh,Hosur,TN44AA1234,900300, ,TN44AA1235,700300, 输入可能不太清楚,请单击 1 : https://i.sstatic.net/ygsw6.png 用于更好的输入视图
Now from the above image , I want to parse the data from csv/excel to the a List owners. Can someone help me on how to do that?
class Owner{
String name;
String address;
List<Vehicle> vehicle;
}
class Vehicle{
String number;
double price;
}
I am aware I can use a Apache POI for parsing a Excel and Apache Commons for parsing a CSV. My major confusion is how to go ahead and read the file :
Eg: From seeing the image/file I can know that Kumar has four Vehicles but how to translate that to code :(enter image description here
Input:
Name , Address , Vehicle , Price
Kumar, Bangalore,KA01AA1234,900300,
, ,KA01AA1235,700300,
, ,KA01AA1236,560300,
, ,KA01AA1237,770300,
Suresh, Mangalore, KA20AA1234,900300,
, ,KA20AA1235,700300,
, ,KA20AA1236,560300,
Ramesh, Hosur, TN44AA1234,900300,
, ,TN44AA1235,700300,
the input may not be very clear please click 1: https://i.sstatic.net/YGsw6.png for better input view
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论