Understanding Data Structures

This section demonstrates data structures that are frequently used in automation scenarios. When working with various data files, we have to analyze their structure, extract the relevant values from fields of interest, and print them on labels.

Binary Files

Binary files contain plain text and binary characters, such as control codes (characters below ASCII code 32). The Unstructured Data Filter supports binary characters. You can use binary characters to define fields positions, and you can also use binary characters for field values.

Typical example would be data export from a legacy system, in which the data for each label is delimited with a Form Feed character <FF>.

Example

In this case, Automation trigger captures the print stream. The yellow-highlighted data section must be extracted from the stream and sent to a different printer. The filter is configured to search for <FF> as field-end position.

UUID-0ccf77b5-e82e-e100-c7e2-d3586509200d.png

Command Files

Command files are plain text files containing commands that are executed one at a time from top to bottom. Loftware Automation supports native command files, as well as Oracle and SAP XML command files. For more information see section Command Files Specifications, Oracle XML Specifications, and SAP AII XML Specifications.

Example

The label label2.nlbl is going to print to CAB A3 203DPI printer.

LABEL "label2.nlbl"
SET code="12345"
SET article="FUSILLI"
SET ean="383860026501"
SET weight="1,0 kg"
PRINTER "CAB A3 203DPI"
PRINT 1

Compound CSV

Compound CSV is a text file that contains data in two structures – in a standard CSV structure, and in a multi-line header that uses a non-standard structure. The contents of a compound CSV file cannot be parsed using a single filter. To parse data in both structures, configure two separate filters:

Configuration that includes a compound CSV file, requires two actions to execute both filters on the received data.

Example

Data items from line 3 until the end of the document have CSV structure and are parsed by the Structured Text filter. Data items in the first two lines do not have any particular structure and are parsed using Unstructured Data filter.

                            
                                OPTPEPPQPF0
                             NL004002 ;F75-TEP77319022891-001-001
OPT2 zg2lbprt.p 34.1.7.7 GOLF+ label print"printer";"label";"lbl_qty";"f_logo";"f_field_1";"f_field_2";"f_field_3"
"Production01";"label.nlbl";"1";"logo-nicelabel.png";"ABCS1161P";"Post: ";"1"
"Production01";"label.nlbl";"1";"logo-nicelabel.png";"ABCS1162P";"Post: ";"2"
"Production01";"label.nlbl";"1";"logo-nicelabel.png";"ABCS1163P";"Post: ";"3"
"Production01";"label.nlbl";"1";"logo-nicelabel.png";"ABCS1164P";"Post: ";"4"
"Production01";"label.nlbl";"1";"logo-nicelabel.png";"ABCS1165P";"Post: ";"5"

Legacy Data

Legacy data are unstructured or semi-structured exports from legacy applications. These exports do not use CSV or XML data structures. To extract relevant data from such files, use the Unstructured Data Filter and define the positions of fields of interest. The filter in Automation extracts field values and makes them available for printing on labels.

Example

The file below follows no structure related rules. Each field must be configured manually.

                            
                                HAWLEY
                                 ANNIE     ER12345678 ABC     XYZ
                9876543210
PRE OP     07/11/12     F 27/06/47     St. Ken Hospital     3

G015 134 557 564 9     A- 08/11/12     LDBS F-         PB     1
G015 134 654 234 0     A- 08/11/12     LDBS F-         PB     2
G015 134 324 563 C     A- 08/11/12     LDBS F-         PB     3
   


                Antibody Screen: Negative
    Store Sample :
    SAMPLE VALID FOR 24 HOURS, NO TRANSFUSION HISTORY SUPPLIED

07/11/12     B,31.0001245.E     O Rh(D) Pos         PHO
                        RLUH     BT

Text Database

Text database is an alias for text files with structured fields, such as CSV (comma separated file), or text files with fixed-width fields. In either case, you can click the Import Data Structure button and follow the wizard to import the fields. If you have a data file with delimited structure and the number of fields varies from one copy to another, enable the Dynamic structure feature and let Loftware Automation handle the data extraction and mapping to variables automatically. For more information, see section Enabling Dynamic Structure.

Example

  • File with delimited fields: The first line in the file contains field names that the filter can import.

    Product_ID;Code_EAN;Product_desc;Package
    CAS006;8021228110014;CASONCELLI ALLA CARNE 250G;6
    PAS501;8021228310001;BIGOLI 250G;6
    PAS502GI;8021228310018;TAGLIATELLE 250G;6
    PAS503GI;8021228310025;TAGLIOLINI 250G;6
    PAS504;8021228310032;CAPELLI D'ANGELO 250G;6
  • File with fixed-width fields: Fields contain a fixed number of characters.

    CAS006     8021228110014 CASONCELLI ALLA CARNE 250G 6
    PAS501     8021228310001 BIGOLI 250G                6
    PAS502GI   8021228310018 TAGLIATELLE 250G           6
    PAS503GI   8021228310025 TAGLIOLINI 250G            6
    PAS504     8021228310032 CAPELLI D'ANGELO 250G      6

XML Data

XML stands for eXtensible Markup Language. XML tags are not predefined, you are free to define your own tags to describe the data. XML is designed to be self-descriptive.

XML structure is defined by elements, attributes (and their values), and text (element text).

Examples

JSON Data

JavaScript Object Notation (JSON) is an open-standard file format. JSON uses human-readable text to transmit data objects consisting of name–value pairs, and array data types (or any other serializable value). JSON is a very common data format used for asynchronous browser–server communication, including as a replacement for XML.

There are multiple online resources describing the similarities and differences between JSON and XML. The table below describes a portion of them:

JSON

XML

It is JavaScript Object Notation

It is Extensible markup language

It is based on JavaScript language.

It is derived from SGML.

It is a way of representing objects.

It is a markup language and uses tag structure to represent data items.

It does not provides any support for namespaces.

It supports namespaces.

It supports array.

It doesn’t supports array.

Its files are very easy to read as compared to XML.

Its documents are comparatively difficult to read and interpret.

It doesn’t use end tag.

It has start and end tags.

It is less secure.

It is more secure than JSON.

It doesn’t supports comments.

It supports comments.

It supports only UTF-8 encoding.

It supports various encoding.

Source: https://www.geeksforgeeks.org/difference-between-json-and-xml/