Skip to content

jdegand/ada-school-csv-reader-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ada School CSV Reader Java

Solution to this repo.

Directions

Part 1: Implementing a CSV Reader with Java:

  1. Download, import and run the code of this repository.
  2. Open the TODO tab and implement the code required to transform each line in the file into a Product object.
  3. Create a class called ProductsService and move your code there to store the list of products loaded from the CSV.
  4. Override the toString method of the Product class and run your code to print your products and verify it works as expected.
  5. Create an interface to define how other users could use your library.
  6. Change your code on the main method to use the interface and preview how your library works.

Part 2: Using Maven to avoid re-inventing the wheel:

  1. Read the following article to understand how to add Maven to the Java project
  1. Once your project has the Maven include import the following library into your dependencies:
  1. Read the Open CSV documentation to understand how to use the CSV library:
  1. Modify your code to use the Open CSV library instead of reading and processing line by line.

Thoughts

  • The Maven archetypes are outdated when you create new projects in VS Code. Nothing has really changed in years.
  • I always use double, so I was surprised to see a float used in the starter code.
  • Double can be overkill, and maybe I should use float more often.
  • Scanner and FileReader are slower than BufferedReader.
  • I looked into various CSV libraries. Deephaven CSV seems like an interesting new library. Super CSV seems to be slightly outdated.
  • I thought about using different branches or different classes, but I decided just to comment out different approaches for right now.
  • When you uncomment any section, you will need to add the imports.
  • You need to add an empty constructor to any POJO class for opencsv to parse your CSV file. Otherwise, you will get a CSV bean introspection exception.

Continued Development

  • Different classes or branches for the different approaches

Useful Resources

About

Ada School CSV Reader Java Challenge

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages