I am trying to create two different arrays from separate columns in a csv file. The csv file has one column for 'month's' and one column for 'temperatures'. This is what I have so far but I can't figure out how to turn these values into arrays.
public class InputOutput
{
private double temperature;
public InputOutput()
{
List<String> temperatures = new ArrayList<String>();
Iterator<String> tempIterator = temperatures.iterator();
}
public static double getTemp()
{
double tempReading = 0.0;
try
{
String fileName = "C:\\Users\\Joseph\\Downloads\\MNMINPLS.csv"; //location of MNMINPLS.csv
File file = new File(fileName);
Scanner scan = new Scanner(file); //scanner reads file
while(scan.hasNext()) //iterator
{
String tempData = scan.next();
String[] nums = tempData.split(",");
tempReading = Double.parseDouble(nums[3]);
System.out.println(tempReading);
}//end while
scan.close();
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}//end try/catch
return tempReading;
}//end method getTemp
public static int getMonth()
{
int m = 0;
try
{
String fileName = "C:\\Users\\Joseph\\Downloads\\MNMINPLS.csv"; //location of MNMINPLS.csv
File file = new File(fileName);
Scanner scan = new Scanner(file); //scanner reads file
while(scan.hasNext()) //iterator
{
String month = scan.next();
if(month == month)
m++;
String[] timeOfYear = month.split(",");
m = Integer.parseInt(timeOfYear[0]);
System.out.println(m);
}
scan.close();
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}//end try/catch
return m;
}
}