Hello, I've decided to try and mess around with a dataset I've found online and when it came to writing the code for it, my typical method of using a comma to split between each segment doesn't work for this dataset.
An example of a line within the dataset:
The Legend of Zelda: Ocarina of Time, Nintendo 64,"November 23, 1998","As a young boy, Link is tricked by Ganondorf, the King of the Gerudo Thieves. The evil human uses Link to gain access to the Sacred Realm, where he places his tainted hands on Triforce and transforms the beautiful Hyrulean landscape into a barren wasteland. Link is determined to fix the problems he helped to create, so with the help of Rauru he travels through time gathering the powers of the Seven Sages.",99,9.1
The data is organized as such:
name,platform,release_date,summary,meta_score,user _review
I've tried finding a way to hopefully have it ignore commas within quotations as it seems the commas are within quotations. But no luck.
So the first thing I noticed was that there's a comma within the date, and the program more than likely wouldn't ignore it how I have it set up. Does anyone know a way around this? Here's my code below:
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class GameDataTests { public static void main(String[] args) { File file = new File("all_games.csv"); Scanner input = null; GameEntry[] gameEntries = new GameEntry[231];//Array to hold the objects try { input = new Scanner(file); } catch (FileNotFoundException e) { System.out.println("File not found."); e.printStackTrace(); } input.nextLine();//to read in the header of the text file int index = 0; while(input.hasNext()) { //name,platform,release_date,summary,meta_score,user_review String line = input.nextLine();//each line in the file is read in as a single String segment here String[] fields = line.split(",");//the string segment is then 'split' at every ',' char (see .cvs file) gameEntries[index++] = new GameEntry(fields[0], fields[1], fields[2], fields[3], Integer.parseInt(fields[4]), Double.parseDouble(fields[5])); } input.close(); //At this point, there should be an array of GameEntry objects }//Main }//Class