Sometimes, we want to save data from our game into our local computer, whether for debugging, recording game testing experiments, and so on. The comma-separated variable (CSV) text file format is a good format to save data in since it is easily read into rows and columns by almost all spreadsheet applications.
In this recipe, we'll write a script that offers a method that can be called from anywhere in our game, from any scene, that will add a row of text to a log file. The following is an example of the saved data when viewed in Microsoft Excel:

Figure 13.14 – Log data viewed in a spreadsheet application