Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda