How to validate csv file?

后端 未结 4 780
感情败类
感情败类 2020-12-05 11:29

How can we validate a CSV file ?

I have an CSV file of structure:

Date;Id;Shown
15-Mar-10;231;345
15-Mar-10;232;346
and so on and on !!! approx arou         


        
4条回答
  •  执念已碎
    2020-12-05 12:03

    Expect the data you are reading is valid, and simply ignore any lines that seem invalid or are of an unexpected format.

    CSV is used for data exchange or as a data storage. So it's very likely that it was already “valid” when the files was generated. If you – for whatever reason – have a CSV file as user input (the only real source where invalid or unexpected data can come from), there is no problem with ignoring that data and telling the user about the invalid lines.

提交回复
热议问题