# Convert spreadsheet into academic references (Help!)

**URL:** <https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608>\
**Category:** Coding Questions\
**Created:** [January 2, 2024, 10:38pm UTC](https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608 "2024-01-02T22:38:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![isabela](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/isabela/32/19188_2.png) [@isabela](https://discourse.processing.org/u/isabela)\
**Post date:** [January 2, 2024, 10:38pm UTC](https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608/1 "2024-01-02T22:38:58Z")

</div>

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!)

```auto
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() {
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 2, 2024, 11:05pm UTC](https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608/2 "2024-01-02T23:05:02Z")

</div>

Can you please post the first 5 lines of the csv?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 2, 2024, 11:10pm UTC](https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608/3 "2024-01-02T23:10:08Z")

</div>

> [@isabela](#):
>
> test spreadsheet converted into CSV

Did you look at the file using notepad?

Maybe when you used Excel, it imported with ; instead of using,

You can also try export as tsv (separated by tabs)

* * *

You could also look at loadTable()

But back to your code I have difficulties to see where you  
insert your ; after Author1 for example

But maybe it’s just a version of the code where you tried different things

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 2, 2024, 11:55pm UTC](https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608/4 "2024-01-02T23:55:47Z")

</div>

I assume that the books have different  
numbers of authors.

That makes it a bit difficult to handle.

For example if you have 3 authors you work

- with ` ; ; .`

- For 2: ` ; .`

- For 1: ` .`

So that is difficult.

Maybe it’s similar to other parts, when location is missing e.g…

Anyway you can of course simply delete the  
superfluous ; in the incoming data using `replace()`.

Chrisir

---

<div class="post-metadata">

**Author:** ![isabela](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/isabela/32/19188_2.png) [@isabela](https://discourse.processing.org/u/isabela)\
**Post date:** [January 3, 2024, 12:45am UTC](https://discourse.processing.org/t/convert-spreadsheet-into-academic-references-help/43608/5 "2024-01-03T00:45:19Z")

</div>

In the end I used tsv and loadTable, as you suggested. I managed to create conditions for the variable number of authors. Problem solved, thank you!
