using csv files in unreal engine. ex 1. leaderboards. (preview)

As your projects become more and more involved, there will certainly be a point where you learn about saving and loading data inside of Unreal Engine. The engine’s in-game save file class is great for many reasons, but it is not the best nor the only solution for many cases.
My line of work involves creating short-lived experiences for clients as games, demos, or demonstrations. They are usually repeating experiences so that any of their users will come away with the same amount of information as the previous user. This can take place on a simple keyboard/mouse setup, XR, touchscreen, or custom setup for that client.

In this first example and defense of using simple .txt or .csv files as data collection and distribution, I will write about a practical use of them as leaderboards and data collection on a local machine or between several on the same network.

A company has a product they want to demonstrate with 5 touchscreens at their tradeshow booth.
They would like us to create the visuals of the space to match their brand and the gameplay
to demo their product.

The tradeshow will NOT have internet access, but they would like to have a way to display
the players' scores on a main display they will hang from the ceiling.
Additionally, at the end of the game, a user can put in their contact data such as their
name, email, and questions/comments that they would like to discuss. 

A project brief like this is not at all uncommon and will usually come with a tight deadline. We’re going to ignore all of that for this blog post, and focus on the solution for solving this problem!

Before I get into it, this example can be scaled up and down to suit your needs. You can have this all take place with a single device or spread as far as your hardware allows.

We know they will have 5 different computers for the touchscreens and one very large display. The problem is connecting all of them together, without the internet, all running their own instance of the packaged game and one that is only concerned with reading the leaderboard and displaying the data.

The first thing I would ask the client would be if we can add a computer to be the server to these five “client” computers. Assuming they say yes, the simplified setup would look like this:

Now, instead of using the .sav file from Unreal and loading it on the server, we will use a .csv file.
The reasons being:

  • .Sav is only readable with Unreal Engine
  • .Sav files are overkill for this use
  • Detached (server running a different game that is only the leaderboard) Unreal package could have loading errors
  • .Sav files are non-human readable
  • It is harder to specify the save location of the .Sav files
  • Can ship project without the need to extract the data from the .Sav files and export some other way for client-use

Basically, the .csv file is small, portable, easy to append new data to, and organized by design.


We need several things to get this working. We need the ability to

From the client touchscreen:

  1. access the folder location on the server
  2. format the provided data to the .csv format
  3. load the .csv file (if it exists and create one if it does not)
  4. append the new data to the existing data
  5. override the .csv with this new string of data

From the server:

  • provide access to the folder for client computers to save to
  • load the .csv and save internally
  • check back very frequently for updates*
  • when updates are found, read imported data and sort for display
  • optional: save a .sav from the game every so often as a backup of the data

*The frequency you check back is up to your setup. I usually have it check every 1 or 2 seconds which has been more than enough to simulate a “real-time” update on the display.

The rest of this post will be up soon! It includes the C++ and Blueprints to get this all working.Talk to you then!

Site Footer