Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
OpenCSV writing a CSV file using multiple arrays

I have 7 arrays and I want each array to be a column in a CSV file. I'm currently using OpenCSV. But, I haven't figured out a way to generate a CSV file from multiple arrays.

String[] Title = new String[1000];
String[] Starring = new String[1000];
String[] Director = new String[1000];
CSVWriter writer = new CSVWriter(new FileWriter("export.csv"), ',');
String[] entries = Title[1] + Starring[1].split('#');
writer.writeNext(entries);
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Assuming you have a 2D array of String, here's what you can do:

CSVWriter writer = //get csv writer
String[][] lines = //lines
for(String[] lines : lines){
    writer.writeNext(lines);
}
over 4 years ago · Santiago Trujillo Relatório

0

The writeNext method in openCSV takes an array of String with each element being the value if you have separate arrays you have to build the single array to feed the writeNext. I am not sure if this will work but its worth a shot.

private String[] createRowFromSeparateArrays(String... columns) {
   return columns;
}

And then in your code you would have

for (int i = 0; i < Title.length; i++) {
 writer.writeNext(createRowFromSeparateArrays(Title[i],Starring[i],Director[i]));
}

good luck :)

over 4 years ago · Santiago Trujillo Relatório

0

You first need to create parallel arrays and cast them into String then Parse the actual array toString. GOOD LUCK

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda