# Exporting

An export involves writing data from your working packet tree into some foreign file format. For most formats you can only export small pieces of your packet tree at a time (such as individual triangulations). All exports are done through the File->Export menu.

When you select an action from the File->Export menu, Regina will ask you which packet to export. For most export formats Regina will only export the selected packet, but for some formats (such as Regina's own data format) it will export an entire packet subtree.

After selecting a packet, you will be asked to choose a filename for your export. Regina will then save the exported data to that file.

Regina can export data to the following file formats:

### Regina Data Files

This is Regina's native file format, in which data is saved as compressed XML. Regina can export an entire packet subtree to this format: just choose the root of of the subtree as the packet to export. Regina will export not just the packet you select, but all of the packets beneath it in the tree.

This is a convenient way of extracting a small portion from a larger data file.

The packet that you select for export will become the top-level packet in the new tree (i.e., Regina will not add a new container to the top of the export data file).

There are two menu items for exporting to a Regina data file. If you choose File->Export->Regina Data File, the data will be exported as compressed XML (the standard file format). If you choose File->Export->Regina Data File (Uncompressed), the data will be saved as plain XML (which means you can view the XML in your favourite text editor). Regina is capable of reading data files in either compressed or uncompressed format.

If you simply want to view the raw XML content of an existing data file, you do not need to go to the trouble of exporting it in uncompressed format. Instead you can just pipe the data file through gunzip:

        example$ cat file.rga | gunzip

### SnapPea Triangulations

You can export a 3-manifold triangulation to SnapPea's native file format. This is a plain text format, described in more detail in the section on SnapPea imports.

Not every data file can be exported to SnapPea format. For instance, the triangulation cannot be invalid, and it may not have any boundary triangles. Regina will tell you if your triangulation cannot be exported.

Any international characters in the exported SnapPea file will be encoded using UTF-8.

### 3-Manifold Recogniser Triangulations

You can export a 3-manifold triangulation to a plain text file that can be given as input to Matveev's 3-Manifold Recogniser.

As with the SnapPea format, not every data file can be exported to the 3-Manifold Recogniser. In particular, the triangulation cannot be invalid, and it may not have any boundary triangles. Regina will tell you if your triangulation cannot be exported.

### C++ Source Code

You can export a 3-manifold triangulation as C++ source code. This C++ code will use classes and routines from Regina's calculation engine. When run, this code will reconstruct your triangulation.

Exporting to C++ can be useful if you wish to hard-code a triangulation in your own C++ project. See the separate chapter on building Regina into your own code.

During the export, Regina will tell you how it will write any international characters (that is, letters or symbols not found on a typical English keyboard). Such characters are stored using a text encoding, such as UTF-8 (a popular modern standard and the default in Regina), or LATIN1 (which has a long history of use with many Western European languages). If you wish to use a different encoding, you will need to set this in Regina's options. If you are not sure, the default of UTF-8 is typically a good choice. If you only ever use letters or symbols on a typical English keyboard, you do not need to worry about text encodings at all.

### Spreadsheet-Readable (CSV) Surface Lists

You can export a normal surface list to a plain-text CSV file (comma-separated values), which you can easily import into a spreadsheet or database.

The CSV file will begin with a header row, followed by one line for each normal surface in the list. Surfaces will be exported in standard coordinates (that is, tri-quad coordinates for normal surfaces, or tri-quad-oct coordinates for almost normal surfaces). The fields in the CSV file will mirror the columns that you see in the normal surface coordinate viewer, and will include properties such as Euler characteristic and orientability as well as the surface coordinates themselves.

If any of the surfaces have names that include international characters, these names will be exported in UTF-8.

### PDF Documents

You can export a PDF packet to an ordinary PDF document.

If you simply wish to view PDF packets in a different viewer, you do not need to go to the trouble of exporting the packet—instead you can configure Regina to use your favourite viewer by default.

### Python Scripts

You can export a script packet as a regular Python file. Regina will add a special comment block to the top of the file, describing the packet label and the script variables. This special comment block allows you to import the script seamlessly back into Regina; see Python imports for details.

During the export, Regina will tell you how it will encode any international characters in the script (i.e., letters or symbols not found on a typical English keyboard). See the C++ exports section above for more information on text encodings.