user30341: Running Arduine IDE SD DataLogger Example, my data gets appended to a txt file.
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
  dataFile.println(dataString);
  dataFile.close();
}

Is there an explicit option to open the file in overwrite / append modes?

user31105: If you look in this library, you see:
File SDClass::open(const char *filepath, uint8_t mode) {

    ...

    if ((mode & (O_APPEND | O_WRITE)) == (O_APPEND | O_WRITE)) {

So you can use all these mode combinations (e.g. O_CREATE, O_APPEND, O_WRITE).

user37622: The Arduino SD library is an Arduino wrapper of old version of SdFat library (put into utility subfolder of the SD library). This SdFat library has constants like O_READ, O_WRITE, O_APPEND.
Arduino wrapper has constants
#define FILE_READ O_READ
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)

You can use the SdFa library constants in the wrapper calls.
File dataFile = SD.open("datalog.txt", O_READ | O_WRITE | O_CREAT);

Warning: not all versions of SD library bundled in different board packages have O_APPEND in #define FILE_WRITE. Even in the Arduino SD library the O_APPEND was removed some time ago and then the change was reverted, because all dataloger examples used FILE_WRITE.

user63166: You only need to open the file with FILE_WRITE and use file.seek(EOF) to go to de end of the file. After that you can write whatever you want that will be appended to the end of the file.
File outputFile = SD.open(LOG_FILE, FILE_WRITE);
outputFile.seek(EOF);
outputFile.println("Appended to the EOF");


30341: <p>Running Arduine IDE <code>SD DataLogger Example</code>, my data gets appended to a txt file.</p>

<pre><code>File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
  dataFile.println(dataString);
  dataFile.close();
}
</code></pre>

<p>Is there an explicit option to open the file in overwrite / append modes?</p>
 31105: <p>If you look in <a href="https://github.com/arduino-libraries/SD/blob/master/src/SD.cpp" rel="nofollow noreferrer">this library</a>, you see:</p>

<pre><code>File SDClass::open(const char *filepath, uint8_t mode) {

    ...

    if ((mode &amp; (O_APPEND | O_WRITE)) == (O_APPEND | O_WRITE)) {
</code></pre>

<p>So you can use all these mode combinations (e.g. O_CREATE, O_APPEND, O_WRITE).</p>
 37622: <p>The Arduino SD library is an Arduino wrapper of old version of SdFat library (put into utility subfolder of the SD library). This SdFat library <a href="https://github.com/arduino-libraries/SD/blob/b8a78d4b3bf970c776522b79f95c7cc4691ced3c/src/utility/SdFat.h#L52" rel="nofollow noreferrer">has constants</a> like O_READ, O_WRITE, O_APPEND.</p>

<p>Arduino wrapper has constants</p>

<pre><code>#define FILE_READ O_READ
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)
</code></pre>

<p>You can use the SdFa library constants in the wrapper calls.</p>

<pre><code>File dataFile = SD.open("datalog.txt", O_READ | O_WRITE | O_CREAT);
</code></pre>

<p><strong>Warning</strong>: not all versions of SD library bundled in different board packages have O_APPEND in <code>#define FILE_WRITE</code>. Even in the Arduino SD library the O_APPEND was removed some time ago and then the change was reverted, because all dataloger examples used FILE_WRITE.</p>
 63166: <p>You only need to open the file with <code>FILE_WRITE</code> and use <code>file.seek(EOF)</code> to go to de end of the file. After that you can write whatever you want that will be appended to the end of the file.</p>

<pre><code>File outputFile = SD.open(LOG_FILE, FILE_WRITE);
outputFile.seek(EOF);
outputFile.println("Appended to the EOF");
</code></pre>
