Hello! I’m (trying) to write a simple code to transform job references written in a spreadsheet into text. I started with a test spreadsheet converted into CSV, but I’m having some formatting problems: the information always appears accompanied by “;” and I can’t add the required punctuation.
The correct formatting would be: Author1; Author2; Author3. Title. Location: publisher, year.
I really appreciate the help! (Detail: I’m Brazilian, so I had to translate the code for you. If there is any problem understanding, please let me know!)
String[] lines;
String textFormatted = "";
void setup() {
lines = loadStrings("TS.csv");
for (String line : lines) {
String[] columns = line.split(",");
// Verificando se a coluna está preenchida antes de adicioná-la ao texto formatado
String author1 = columns.length > 0 && !columns[0].isEmpty() ? columns[0] : "";
String author2 = columns.length > 1 && !columns[1].isEmpty() ? columns[1] : "";
String author3 = columns.length > 2 && !columns[2].isEmpty() ? columns[2] : "";
String title = columns.length > 3 && !columns[3].isEmpty() ? ". " + columns[3] : "";
String local = columns.length > 4 && !columns[4].isEmpty() ? ": " + columns[4] : "";
String press = columns.length > 5 && !columns[5].isEmpty() ? ", " + columns[5] : "";
String year = columns.length > 6 && !columns[6].isEmpty() ? columns[6] : "";
textFormatted += author1 + author2 + author3 + title + local + press + year + ".\n";
}
saveStrings("saida_abnt.txt", new String[]{textFormatted});
}
void draw() {
}