我需要编写一个将CSV文件转换为数组列表的Java程序。 CSV行如下所示:
5/3/2010,"Behrens, Michael Lakeside Apts","Lisle, IL 60532",PD: Noise or domestic reports for 3/25 to 4/28 for specific apt.,5/10/2010, 5/10/2010,1
我需要这样:
DATE RECEIVED:5/3/2010 NAME / COMPANY:Behrens, Michael Lakeside Apts CITY, STATE, ZIP:Lisle, IL 60532 Department / Documents:PD: Noise or domestic reports for 3/25 to 4/28 for specific apt. Due Date 5 Days 10 Days:5/10/2010 DATE COMPLETED:5/10/2010 Hours Spent Fulfilling Request:1
到目前为止,我已经得到了这个:,|[\"]
,但我需要从,
中移除""
答案 0 :(得分:4)
你需要的不是正则表达式,而是csv parser (openCSV)。
或者你可以手动使用
之类的东西String[] arr = string.split("(\\\",\\\"|(?<!\\\"),)");
String output = "DATE RECEIVED: " + arr[0] +
"\nZIP: " + ...
"... " + ...;