想要保存和读取多个不是修复格式的csv文件 [英] Wants to save and read multiple csv file which was not in fix format

查看:66
本文介绍了想要保存和读取多个不是修复格式的csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读csv哪个列长度不会修复客户端可以提供多个/单个csv与不同的列数据来完成单个对象(java)。



假设一个文件只包含名字,其他文件可以有年龄或其他细节,但我必须制作一个人的单个对象并插入表格。



我试过的:



i无法成功。我尝试了一些基本的csvReader / Writter,但是如果没有修复csv列,它就不起作用。

I want to read csv which column length will not fixed client can provide multiple/single csv with diffrent column data to complete single object(java).

suppose one file contain only names and other can have age or other details but i have to make single object of person and insert into table.

What I have tried:

i couldn't success. i tried some basic csvReader/Writter but it doesn't work if csv column isn't fixed.

推荐答案

你可以有几个不同长度的.csv文件,但是,需要有一种方法来创建文件之间的关系。您所描述的是一个简单的数据库,将每个.csv文件视为一个表。数据库如何与其他表建立关系是通过使用密钥。为主表的每个新条目分配唯一键。这些键可用于将用户交叉引用到其他表或.csv文件。



下面的示例演示了一个使用键将信息绑定在一起的简单数据库。 />


Main.csv文件

You can have several .csv files with differing lengths, however, there needs to be a way to create a relationship between the files. What you are describing is a simple database, think of each .csv file as a table. How databases make relationships to other tables is through the use of keys. Unique keys are assigned to each new entry to the main table. These keys can be used to cross reference the user to other tables or .csv files.

The example below demonstrates a simple database using keys to tie information together.

Main.csv file
Key,		Name
01,		Bob
02,		Jill
03,		Sam
04,		Mike



BMW.csv文件


BMW.csv file

Key,		Model
02,		i8



Ford.csv文件


Ford.csv File

Key,		Model
03,		Fusion
04,		Focus



Fiat.csv文件


Fiat.csv File

Key,		Model
01,		124 Spider



使用示例数据库,我们可以通过匹配键创建人员列表以及他们驾驶的汽车类型。



鲍勃,菲亚特124蜘蛛

吉尔,宝马i8

山姆,福特Fusion

迈克,福特福克斯



问候。


Using the example database, we can create a list of people and what type of car they drive by matching the keys.

Bob, Fiat 124 Spider
Jill, BMW i8
Sam, Ford Fusion
Mike, Ford Focus

Regards.


这篇关于想要保存和读取多个不是修复格式的csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆