Yes. Make a string with the machine names. At the top of the prog, with your other variables.
String machineNames = "Press 2a, Press 2b, ... ";
We need to detect if the file exists. Have to do this after we know the name, and before we open it. Then after we’ve opened the file, if it didn’t exist, write the title line. I didn’t know how to check if a file exists but @GoToLoop has done it. Put this after the other functions we added earlier.
boolean fileExists(String filename) {
File f = dataFile(filename);
String filePath = f.getPath();
boolean exist = f.isFile();
println(filePath, exist);
return exist;
}
Put this after we made the filename with the date in it.
boolean csvFileExists
csvFileExists = fileExists("@sketchPath + "/" + filename")
(that has to be the same filespec as in the open, we should rationalise that but never mind now.) After the open we need to conditionally write the new line.
if (!csvFileExists) {
output.write("DateTime," + machineNames);
}