JAVA convert string CSV file into double[] array
I have an issue with the CSV file: here is a sample of the file.
4.98 24
9.14 21.6
4.03 34.7
2.94 33.4
5.33 36.2
5.21 28.7
12.43 22.9
19.15 27.1
29.93 16.5
17.1 18.9
20.45 15
13.27 18.9
15.71 21.7
8.26 20.4
10.26 18.2
8.47 19.9
6.58 23.1
14.67 17.5
11.69 20.2
11.28 18.2
The aim is to convert it in something like that:
double column1= {4.98, 9.14, 4.03, 2.94, 5.33, 5.21, 12.43, 19.15}; //but with all the values, here it's just a sample
double column2 = {24, 21.6, 34.7, 33.4, 36.2, 28.7, 22.9, 27.1};
I don't want to write all the data, I need to do a loop but I don't know how I can do it.
I manage to read the csv file and to split the data but not to convert the result into a double array. Here is how I read the file:
String fileName = "dataset.csv";
File file = new File(fileName);
String values;
try{
Scanner inputStream = new Scanner(file);
while (inputStream.hasNext()){
String data = inputStream.next();
values = data.split(",");
}
inputStream.close();
}
catch (FileNotFoundException e){
e.printStackTrace();
}
java arrays csv double
add a comment |
I have an issue with the CSV file: here is a sample of the file.
4.98 24
9.14 21.6
4.03 34.7
2.94 33.4
5.33 36.2
5.21 28.7
12.43 22.9
19.15 27.1
29.93 16.5
17.1 18.9
20.45 15
13.27 18.9
15.71 21.7
8.26 20.4
10.26 18.2
8.47 19.9
6.58 23.1
14.67 17.5
11.69 20.2
11.28 18.2
The aim is to convert it in something like that:
double column1= {4.98, 9.14, 4.03, 2.94, 5.33, 5.21, 12.43, 19.15}; //but with all the values, here it's just a sample
double column2 = {24, 21.6, 34.7, 33.4, 36.2, 28.7, 22.9, 27.1};
I don't want to write all the data, I need to do a loop but I don't know how I can do it.
I manage to read the csv file and to split the data but not to convert the result into a double array. Here is how I read the file:
String fileName = "dataset.csv";
File file = new File(fileName);
String values;
try{
Scanner inputStream = new Scanner(file);
while (inputStream.hasNext()){
String data = inputStream.next();
values = data.split(",");
}
inputStream.close();
}
catch (FileNotFoundException e){
e.printStackTrace();
}
java arrays csv double
1
create two array lists of doubles,column1
,column2
, addvalues[0]
tocolumn1
andvalues[1]
tocolumn2
, after reading all entries, convert lists to arrays usingcolumn1values = column1.toArray( new Double{} )
– SomeDude
May 23 '17 at 14:45
values = data.split(","); be careful with that, because even your csv(since you say so) file shows that there is no such character as ','(comma) in the whole file
– ShayHaned
May 23 '17 at 14:47
It's a CSV file, we can't see the comma because I opened it with Excel but there are commas
– anna756825
May 23 '17 at 14:50
@svasa thank you for your answer, I'm going to try :) ShayHaned thanks for your advice, I will be careful !
– anna756825
May 23 '17 at 14:52
add a comment |
I have an issue with the CSV file: here is a sample of the file.
4.98 24
9.14 21.6
4.03 34.7
2.94 33.4
5.33 36.2
5.21 28.7
12.43 22.9
19.15 27.1
29.93 16.5
17.1 18.9
20.45 15
13.27 18.9
15.71 21.7
8.26 20.4
10.26 18.2
8.47 19.9
6.58 23.1
14.67 17.5
11.69 20.2
11.28 18.2
The aim is to convert it in something like that:
double column1= {4.98, 9.14, 4.03, 2.94, 5.33, 5.21, 12.43, 19.15}; //but with all the values, here it's just a sample
double column2 = {24, 21.6, 34.7, 33.4, 36.2, 28.7, 22.9, 27.1};
I don't want to write all the data, I need to do a loop but I don't know how I can do it.
I manage to read the csv file and to split the data but not to convert the result into a double array. Here is how I read the file:
String fileName = "dataset.csv";
File file = new File(fileName);
String values;
try{
Scanner inputStream = new Scanner(file);
while (inputStream.hasNext()){
String data = inputStream.next();
values = data.split(",");
}
inputStream.close();
}
catch (FileNotFoundException e){
e.printStackTrace();
}
java arrays csv double
I have an issue with the CSV file: here is a sample of the file.
4.98 24
9.14 21.6
4.03 34.7
2.94 33.4
5.33 36.2
5.21 28.7
12.43 22.9
19.15 27.1
29.93 16.5
17.1 18.9
20.45 15
13.27 18.9
15.71 21.7
8.26 20.4
10.26 18.2
8.47 19.9
6.58 23.1
14.67 17.5
11.69 20.2
11.28 18.2
The aim is to convert it in something like that:
double column1= {4.98, 9.14, 4.03, 2.94, 5.33, 5.21, 12.43, 19.15}; //but with all the values, here it's just a sample
double column2 = {24, 21.6, 34.7, 33.4, 36.2, 28.7, 22.9, 27.1};
I don't want to write all the data, I need to do a loop but I don't know how I can do it.
I manage to read the csv file and to split the data but not to convert the result into a double array. Here is how I read the file:
String fileName = "dataset.csv";
File file = new File(fileName);
String values;
try{
Scanner inputStream = new Scanner(file);
while (inputStream.hasNext()){
String data = inputStream.next();
values = data.split(",");
}
inputStream.close();
}
catch (FileNotFoundException e){
e.printStackTrace();
}
java arrays csv double
java arrays csv double
edited Jan 2 at 4:39
Mureinik
184k22136203
184k22136203
asked May 23 '17 at 14:40
anna756825anna756825
82
82
1
create two array lists of doubles,column1
,column2
, addvalues[0]
tocolumn1
andvalues[1]
tocolumn2
, after reading all entries, convert lists to arrays usingcolumn1values = column1.toArray( new Double{} )
– SomeDude
May 23 '17 at 14:45
values = data.split(","); be careful with that, because even your csv(since you say so) file shows that there is no such character as ','(comma) in the whole file
– ShayHaned
May 23 '17 at 14:47
It's a CSV file, we can't see the comma because I opened it with Excel but there are commas
– anna756825
May 23 '17 at 14:50
@svasa thank you for your answer, I'm going to try :) ShayHaned thanks for your advice, I will be careful !
– anna756825
May 23 '17 at 14:52
add a comment |
1
create two array lists of doubles,column1
,column2
, addvalues[0]
tocolumn1
andvalues[1]
tocolumn2
, after reading all entries, convert lists to arrays usingcolumn1values = column1.toArray( new Double{} )
– SomeDude
May 23 '17 at 14:45
values = data.split(","); be careful with that, because even your csv(since you say so) file shows that there is no such character as ','(comma) in the whole file
– ShayHaned
May 23 '17 at 14:47
It's a CSV file, we can't see the comma because I opened it with Excel but there are commas
– anna756825
May 23 '17 at 14:50
@svasa thank you for your answer, I'm going to try :) ShayHaned thanks for your advice, I will be careful !
– anna756825
May 23 '17 at 14:52
1
1
create two array lists of doubles,
column1
, column2
, add values[0]
to column1
and values[1]
to column2
, after reading all entries, convert lists to arrays using column1values = column1.toArray( new Double{} )
– SomeDude
May 23 '17 at 14:45
create two array lists of doubles,
column1
, column2
, add values[0]
to column1
and values[1]
to column2
, after reading all entries, convert lists to arrays using column1values = column1.toArray( new Double{} )
– SomeDude
May 23 '17 at 14:45
values = data.split(","); be careful with that, because even your csv(since you say so) file shows that there is no such character as ','(comma) in the whole file
– ShayHaned
May 23 '17 at 14:47
values = data.split(","); be careful with that, because even your csv(since you say so) file shows that there is no such character as ','(comma) in the whole file
– ShayHaned
May 23 '17 at 14:47
It's a CSV file, we can't see the comma because I opened it with Excel but there are commas
– anna756825
May 23 '17 at 14:50
It's a CSV file, we can't see the comma because I opened it with Excel but there are commas
– anna756825
May 23 '17 at 14:50
@svasa thank you for your answer, I'm going to try :) ShayHaned thanks for your advice, I will be careful !
– anna756825
May 23 '17 at 14:52
@svasa thank you for your answer, I'm going to try :) ShayHaned thanks for your advice, I will be careful !
– anna756825
May 23 '17 at 14:52
add a comment |
2 Answers
2
active
oldest
votes
Here's a full working example for Java 7:
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Example
{
public static void main(String args)
{
Scanner inputStream = null;
try
{
String fileName = "dataset.csv";
File file = new File(fileName);
// we don't know the amount of data ahead of time so we use lists
List<Double> col1 = new ArrayList<>();
List<Double> col2 = new ArrayList<>();
inputStream = new Scanner(file);
while (inputStream.hasNext())
{
String data = inputStream.next();
String arr = data.split(",");
col1.add(Double.parseDouble(arr[0]));
col2.add(Double.parseDouble(arr[1]));
}
// Covert the lists to double arrays
double column1 = new double[col1.size()];
double column2 = new double[col2.size()];
for (int i = 0; i < col1.size(); i++)
{
column1[i] = col1.get(i);
}
for (int i = 0; i < col2.size(); i++)
{
column2[i] = col2.get(i);
}
// print out just for verification
System.out.println(Arrays.toString(column1));
System.out.println(Arrays.toString(column2));
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (inputStream != null)
{
inputStream.close();
}
}
}
}
add a comment |
You can stream the lines from the file and split them to get a String
, as you did. You can then stream each such array and convert each item to a double
, and then collect them back to arrays:
double data =
Files.lines(Paths.get(fileName))
.map(s -> s.split(","))
.map(s -> Arrays.stream(s).mapToDouble(Double::parseDouble).toArray())
.toArray(double::new);
1
s
seems like a bad choice for the name of the array variable here.
– Michael Markidis
May 23 '17 at 14:57
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
1
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44137929%2fjava-convert-string-csv-file-into-double-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here's a full working example for Java 7:
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Example
{
public static void main(String args)
{
Scanner inputStream = null;
try
{
String fileName = "dataset.csv";
File file = new File(fileName);
// we don't know the amount of data ahead of time so we use lists
List<Double> col1 = new ArrayList<>();
List<Double> col2 = new ArrayList<>();
inputStream = new Scanner(file);
while (inputStream.hasNext())
{
String data = inputStream.next();
String arr = data.split(",");
col1.add(Double.parseDouble(arr[0]));
col2.add(Double.parseDouble(arr[1]));
}
// Covert the lists to double arrays
double column1 = new double[col1.size()];
double column2 = new double[col2.size()];
for (int i = 0; i < col1.size(); i++)
{
column1[i] = col1.get(i);
}
for (int i = 0; i < col2.size(); i++)
{
column2[i] = col2.get(i);
}
// print out just for verification
System.out.println(Arrays.toString(column1));
System.out.println(Arrays.toString(column2));
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (inputStream != null)
{
inputStream.close();
}
}
}
}
add a comment |
Here's a full working example for Java 7:
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Example
{
public static void main(String args)
{
Scanner inputStream = null;
try
{
String fileName = "dataset.csv";
File file = new File(fileName);
// we don't know the amount of data ahead of time so we use lists
List<Double> col1 = new ArrayList<>();
List<Double> col2 = new ArrayList<>();
inputStream = new Scanner(file);
while (inputStream.hasNext())
{
String data = inputStream.next();
String arr = data.split(",");
col1.add(Double.parseDouble(arr[0]));
col2.add(Double.parseDouble(arr[1]));
}
// Covert the lists to double arrays
double column1 = new double[col1.size()];
double column2 = new double[col2.size()];
for (int i = 0; i < col1.size(); i++)
{
column1[i] = col1.get(i);
}
for (int i = 0; i < col2.size(); i++)
{
column2[i] = col2.get(i);
}
// print out just for verification
System.out.println(Arrays.toString(column1));
System.out.println(Arrays.toString(column2));
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (inputStream != null)
{
inputStream.close();
}
}
}
}
add a comment |
Here's a full working example for Java 7:
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Example
{
public static void main(String args)
{
Scanner inputStream = null;
try
{
String fileName = "dataset.csv";
File file = new File(fileName);
// we don't know the amount of data ahead of time so we use lists
List<Double> col1 = new ArrayList<>();
List<Double> col2 = new ArrayList<>();
inputStream = new Scanner(file);
while (inputStream.hasNext())
{
String data = inputStream.next();
String arr = data.split(",");
col1.add(Double.parseDouble(arr[0]));
col2.add(Double.parseDouble(arr[1]));
}
// Covert the lists to double arrays
double column1 = new double[col1.size()];
double column2 = new double[col2.size()];
for (int i = 0; i < col1.size(); i++)
{
column1[i] = col1.get(i);
}
for (int i = 0; i < col2.size(); i++)
{
column2[i] = col2.get(i);
}
// print out just for verification
System.out.println(Arrays.toString(column1));
System.out.println(Arrays.toString(column2));
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (inputStream != null)
{
inputStream.close();
}
}
}
}
Here's a full working example for Java 7:
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Example
{
public static void main(String args)
{
Scanner inputStream = null;
try
{
String fileName = "dataset.csv";
File file = new File(fileName);
// we don't know the amount of data ahead of time so we use lists
List<Double> col1 = new ArrayList<>();
List<Double> col2 = new ArrayList<>();
inputStream = new Scanner(file);
while (inputStream.hasNext())
{
String data = inputStream.next();
String arr = data.split(",");
col1.add(Double.parseDouble(arr[0]));
col2.add(Double.parseDouble(arr[1]));
}
// Covert the lists to double arrays
double column1 = new double[col1.size()];
double column2 = new double[col2.size()];
for (int i = 0; i < col1.size(); i++)
{
column1[i] = col1.get(i);
}
for (int i = 0; i < col2.size(); i++)
{
column2[i] = col2.get(i);
}
// print out just for verification
System.out.println(Arrays.toString(column1));
System.out.println(Arrays.toString(column2));
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (inputStream != null)
{
inputStream.close();
}
}
}
}
answered May 23 '17 at 15:34
Michael MarkidisMichael Markidis
3,8581921
3,8581921
add a comment |
add a comment |
You can stream the lines from the file and split them to get a String
, as you did. You can then stream each such array and convert each item to a double
, and then collect them back to arrays:
double data =
Files.lines(Paths.get(fileName))
.map(s -> s.split(","))
.map(s -> Arrays.stream(s).mapToDouble(Double::parseDouble).toArray())
.toArray(double::new);
1
s
seems like a bad choice for the name of the array variable here.
– Michael Markidis
May 23 '17 at 14:57
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
1
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
|
show 3 more comments
You can stream the lines from the file and split them to get a String
, as you did. You can then stream each such array and convert each item to a double
, and then collect them back to arrays:
double data =
Files.lines(Paths.get(fileName))
.map(s -> s.split(","))
.map(s -> Arrays.stream(s).mapToDouble(Double::parseDouble).toArray())
.toArray(double::new);
1
s
seems like a bad choice for the name of the array variable here.
– Michael Markidis
May 23 '17 at 14:57
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
1
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
|
show 3 more comments
You can stream the lines from the file and split them to get a String
, as you did. You can then stream each such array and convert each item to a double
, and then collect them back to arrays:
double data =
Files.lines(Paths.get(fileName))
.map(s -> s.split(","))
.map(s -> Arrays.stream(s).mapToDouble(Double::parseDouble).toArray())
.toArray(double::new);
You can stream the lines from the file and split them to get a String
, as you did. You can then stream each such array and convert each item to a double
, and then collect them back to arrays:
double data =
Files.lines(Paths.get(fileName))
.map(s -> s.split(","))
.map(s -> Arrays.stream(s).mapToDouble(Double::parseDouble).toArray())
.toArray(double::new);
answered May 23 '17 at 14:52
MureinikMureinik
184k22136203
184k22136203
1
s
seems like a bad choice for the name of the array variable here.
– Michael Markidis
May 23 '17 at 14:57
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
1
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
|
show 3 more comments
1
s
seems like a bad choice for the name of the array variable here.
– Michael Markidis
May 23 '17 at 14:57
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
1
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
1
1
s
seems like a bad choice for the name of the array variable here.– Michael Markidis
May 23 '17 at 14:57
s
seems like a bad choice for the name of the array variable here.– Michael Markidis
May 23 '17 at 14:57
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
It seems to be a good idea ! Can you tell me which imports I need to do ? I tried: import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Stream; but it is not working
– anna756825
May 23 '17 at 14:59
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
@anna756825 Can you elaborate on "not working"? What exactly is the problem?
– Mureinik
May 23 '17 at 15:00
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
Well I have errors: "data", "Files" and "Paths" are highlighted just as if the import are not the good ones
– anna756825
May 23 '17 at 15:03
1
1
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
I have juste realized it's Java8, do you know how I can do with Java7 ?
– anna756825
May 23 '17 at 15:17
|
show 3 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44137929%2fjava-convert-string-csv-file-into-double-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
create two array lists of doubles,
column1
,column2
, addvalues[0]
tocolumn1
andvalues[1]
tocolumn2
, after reading all entries, convert lists to arrays usingcolumn1values = column1.toArray( new Double{} )
– SomeDude
May 23 '17 at 14:45
values = data.split(","); be careful with that, because even your csv(since you say so) file shows that there is no such character as ','(comma) in the whole file
– ShayHaned
May 23 '17 at 14:47
It's a CSV file, we can't see the comma because I opened it with Excel but there are commas
– anna756825
May 23 '17 at 14:50
@svasa thank you for your answer, I'm going to try :) ShayHaned thanks for your advice, I will be careful !
– anna756825
May 23 '17 at 14:52