Java: CSV file read & write

前端 未结 7 1558
南旧
南旧 2020-12-10 08:18

I\'m reading 2 csv files: store_inventory & new_acquisitions.
I want to be able to compare the store_inventory csv file with <

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 08:50

    Your implementation makes the common mistake of breaking the line on commas by using line.split(","). This does not work because the values themselves might have commas in them. If that happens, the value must be quoted, and you need to ignore commas within the quotes. The split method can not do this -- I see this mistake a lot.

    Here is the source of an implementation that does it correctly: http://agiletribe.wordpress.com/2012/11/23/the-only-class-you-need-for-csv-files/

提交回复
热议问题