[英]How do i compare csvs which don't have headers for format and data difference in java
I have a pair of similar CSV's without header rows.I have to compare them for format and data differences,how do I parse them so that i may know data type for the parsed string values.ie, I have to identify if the parsed string is a date or time or currency or normal string.Currently I am using Apache Commons CSV parser( without header constructor)but I am unable to compare the CSV's as I don't know which value corresponds to which type?please help.我有一对没有 header 行的类似 CSV。我必须比较它们的格式和数据差异,如何解析它们以便我可以知道解析字符串值的数据类型。即,我必须确定解析字符串是否是日期或时间或货币或普通字符串。目前我正在使用 Apache Commons CSV 解析器(没有 header 构造函数)但我不知道哪个值对应于 CSV 作为构造函数?
I would read the first line of each csv and use regular expressions to sort them into the different categories.我会阅读每个 csv 的第一行并使用正则表达式将它们分类到不同的类别中。 If you're not looking for a super clean way, you can maybe just check if certain special characters are contained within the string like the currency symbols and sort them out that way.如果您不是在寻找一种超级干净的方式,您可以只检查字符串中是否包含某些特殊字符(如货币符号)并以这种方式对它们进行排序。 If it doesnt have a currency symbol then it could be a date or normal string.如果它没有货币符号,那么它可能是日期或普通字符串。 If it doesnt have '-' either then it's a normal string.如果它也没有'-',那么它就是一个普通的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.