When it comes to parsing CSV files, the way you go about doing it is relatively the same (hence the need for the standard format, right?):
- Read the file
- Break each line into an entry into a collection
- Iterate through the collection
- Create an object or element with attributes based on the data in the current given line
Sure, this is a high-level view of how it’s done, and your specific implementation may have finer nuances, but – as I mentioned – I think its safe to say that the way we go about parsing a file is the same regarding of what we do with the data once we start reading it.
When you’re working on an implementation of CSV parser and you’re accepting data from an upload, then there are several things that need to be checked such as the validity of the file type.
For example: If a person uploads an image, you don’t want to proceed with parsing it; however, if they upload an actual CSV, you obviously want to process the file.
But this can be tricky depending on the operating system.
