-2
I have a. CSV file with several numbers in two columns (1032,54832). I need to take these numbers and pass them to an array. How do I do this?
I made a code to import the file and I can display the numbers, but when it comes to passing the values to the vector, I’m having problems. Below follows what I did (This code is inside a button that displays the numbers inside the file. CSV):
String LineFile = new String ();
File fileCSV = new File(LocalFile.getText());
try
{
Scanner reader = new Scanner(fileCSV);
while (reader.hasNext())
{
LineFile = reader.nextLine();
String numb[] = LineFile.split(",");
System.out.println(LineFile);
}
}
catch (FileNotFoundException e)
{
}
Didn’t you already ask that question? Erased and recreated?
– user28595
Yes. I reworked the question and deleted the previous post.
– Gabriel Augusto
I recommend that you avoid doing this, as the system computes negatively excluded question for your profile, which may result in prohibitions from creating new posts on the site. ALWAYS choose to edit and improve the same post.
– user28595
You are getting the array given by
split
but does nothing with it. Missing add to an array. And if you have some kind of mistake then you need to include the error in the question, so that it is clear what problem you are dealing with– Isac
I appreciate the warning. Stack Overflow’s system policy is terrible on these issues.
– Gabriel Augusto
And another, Voce does not explain what problems you are having, your question is not very clear, besides the code nor be reproducible. I suggest you edit and explain better at what point you are having difficulties, because with a piece of code q is not even possible to execute, it is difficult to help without understanding the problem
– user28595
How do I not explain? The problem I’m having is passing the values to an array. If the code wasn’t working, then my question would be about the code not working. And in my eclipse is working normally.
– Gabriel Augusto
Then provide a code that is a [mcve], so it is possible to test and verify the problem
– user28595
It’s a minimal example. It’s the script that I ran through the CSV file.
– Gabriel Augusto
It is not a minimal, complete and verifiable example, if I paste it and run, nothing will happen. I recommend that you read the link, it is no use to stay resistant and not provide what is requested, who harms themselves not getting help is even Voce. Who comes in the comments is because want to help you, but if you are not willing to provide as requested, Oce complicates and delays even more a solution.
– user28595
You say in the question that you are having problems. What problem exactly?
– StatelessDev
Stateless Dev I’m having trouble passing the file values to the array (or to the arrayList, in this case).
– Gabriel Augusto