Skip to content

Browsing CSV files

Florine W. Dekker edited this page May 23, 2022 · 7 revisions

CSV files are exactly like simple spreadsheets: They contain rows and columns, with each row describing an entry and each column describing a property. This page lists details on how to open them and on how to interpret them.

Editors

Broadly speaking, there are three types of editors for CSV files: text editors, spreadsheet editors, and relational databases. The recommended method is to use SQLite Browser to open the .db file from the release.

Text editor

By far the simplest way is to use a text editor such as Microsoft Notepad, Notepad++, or Sublime Text. The last of these three is known for being able to handle large files very well. Programs such as Microsoft Word and OpenOffice Writer work as well, but will be very slow when working with larger files.

The major drawbacks of this approach are that it is not possible to sort or filter entries, and that rows containing large amounts of data cannot easily be browsed.

Spreadsheet editor

Another approach is to use a spreadsheet editor such as Microsoft Excel or OpenOffice Calc. When a CSV is opened using a spreadsheet editor, the program will open an import dialog asking for a number of settings. The CSVs in this repository use a comma (,) as their separator, and the quotation marks (") as text delimiters. Whether you include the first row with the column names is up to you.

After importing the CSV, you can apply filters to the data. For more information on how to do this, check here for Microsoft Office or here for OpenOffice Calc.

A major drawback of this approach is that rows containing large amounts of data cannot easily be browsed.

Relational database

A third option is to use a relational database such as MySQL, PostgreSQL, or SQLite. Relational databases have the advantage that they are very quick at searching through large files, and allow you to perform advanced queries if you know how to write them.

By far the easiest option is to use the SQLite Browser, a user interface for relational databases which does not require any knowledge of databases or SQL. This repository's releases always have a .db file attached to them which can be opened by SQLite. Check the SQLite Browser wiki for more information on how to use SQLite Browser.

The .db files in the releases already have all CSV files imported into them. If you want, you can import more CSV files into the database. As with opening a CSV with a spreadsheet editor, there are several options when importing the file. Again, this repository uses commas (,) to separate values and quotation marks (") as text delimiters. This time around, it is important that you indicate that the first row contains headers, as the column names will be treated as if they were regular values otherwise.

Flattened lists

Each datum in a CSV file is represented as a single row. However, NPCs, for example, belong to multiple factions, so each row should contain a list of factions. This is achieved by "flattening" (or "serializing") the lists so that they can be put on a single row. These dumps make use of JSON to do that. For example, a list containing the factions human, vendor, and raider will look like ["human", "vendor", "raider"].

When flattened lists become very long, it may be difficult to search for a particular piece of data. Luckily, because JSON is a well-recognized format, some editors can help you with this. As shown in the screenshot to the right, SQLite Browser can "unflatted" (or "deserialize") the list for you so that you can search through it quickly.

You can follow the following steps to enable this feature.

  1. In the Browse Data view, click on the cell containing the flattened list.
  2. Ensure that View > Edit Database Cell is enabled.
  3. In the Edit Database Cell, change the Mode to JSON.
  4. In the Edit Database Cell, enable Auto-format.