简体   繁体   中英

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.

I would read the first line of each csv and use regular expressions to sort them into the different categories. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM