Skip to content
Frank Stüber edited this page Oct 19, 2023 · 3 revisions

Creating DIF files

Untis is able to export its data as DIF files which are comma-separated text files. Each DIF file covers a certain data aspect of Untis (e.g. GPU014.txt exports substitution data). You have two options to create DIF files from Untis:

1. Interactive

You can export your data to DIF files from within Untis (see File > Import/Export > Export TXT files).

2. Command line

You can use the command line to automate this task.

The syntax for exporting a single DIF file is:

Untis <Name of your gpn file> /exp<xxx>[=<Name of output file>]

The syntax for exporting all available DIF files is:

Untis <Name of your gpn file> /exp*[=<Name of output folder>]

Examples:

"c:\Program Files\Untis\2020\Untis" c:\data\sample.gpn /exp001=c:\data\GPU001.txt
"c:\Program Files\Untis\2020\Untis" c:\data\sample.gpn /exp*=c:\data

For Untis MultiUser the syntax is different. Here the syntax is:

Untis DB~<School Id>~<School Year Code>~<Version> /exp<xxx>[=<Name of output file>] /user=<Username> /pw=<Password>

The syntax for exporting all available DIF files is:

Untis DB~<School Id>~<School Year Code>~<Version> /exp*[=<Name of output folder>] /user=<Username> /pw=<Password>

Examples:

"c:\Program Files\Untis\2020\Untis" DB~12345~2020-2021~1 /exp001=c:\data\GPU001.txt /user=Administrator /pw=qwertz
"c:\Program Files\Untis\2020\Untis" DB~12345~2020-2021~1 /exp*=c:\data /user=Administrator /pw=qwertz

🔥 Please have a look at PSUntis, a PowerShell Module which encapsulates the Untis command-line interface.

Consuming DIF files

The ENBREA UNTIS.GPU library provides the GpuReader class for parsing certain DIF files into entity objects which can be used for further processing. For each supported DIF file, you will find a corresponding entity class.

Class name Description
GpuTimeElement A record from a GPU001.TXT file
GpuLesson A record from a GPU002.TXT file
GpuClass A record from a GPU003.TXT file
GpuTeacher A record from a GPU004.TXT file
GpuRoom A record from a GPU005.TXT file
GpuSubject A record from a GPU006.TXT file
GpuDepartment A record from a GPU007.TXT file
GpuSupervision A record from a GPU009.TXT file
GpuStudent A record from a GPU010.TXT file
GpuLessonTable A record from a GPU011.TXT file
GpuAbsenceReason A record from a GPU012.TXT file
GpuAbsences A record from a GPU013.TXT file
GpuSubstitution A record from a GPU014.TXT file
GpuStudentCourseChoice A record from a GPU015.TXT file
GpuExam A record from a GPU017.TXT file
GpuHoliday A record from a GPU018.TXT file

Example

The following sample code reads a GPU002.txt file and writes data to the console output.

// Open DIF file
using var strReader = new StreamReader("c:\\data\\GPU002.txt");

// Create CSV Reader
var csvReader = new CsvReader(strReader);

// Default separator for DIF file
csvReader.Configuration.Separator = ',';

// Create Lesson Reader
var gpuReader = new GpuReader<GpuLesson>(csvReader);

// Write data for each lesson to console output
await foreach (var lesson in gpuReader.ReadAsync())
{
    Console.WriteLine(
        $"{lesson.Id}, " +
        $"{lesson.Subject}, " +
        $"{lesson.Class}, " +
        $"{lesson.Teacher}, " +
        $"[{string.Join(", ", lesson.Rooms.ToArray())}], " +
        $"{lesson.ValidFrom}, " +
        $"{lesson.ValidTo}");
}

Have a look at the included unit tests for more examples.

Clone this wiki locally