Skip to content

Conditions Text File Schema Definition Tutorial

This tutorial will show you how to build a Text File Schema Definition that, in addition to the three tutorials previously completed, will also contain the information used to define and validate the Tutorial Text File using Conditions. For this tutorial, we are going to add a Condition, a List and six Values. We are then going to set the new Condition to use the members of the new List. This Condition will indicate that if either of the "State" or "ZIP Code" fields has data, then the other must have data.

Tutorial Text File

last_name,first_name,state,zip_code,price,date,notes
Craig,Kai,OK,73755,15499,12/26/2019,"friendly, prompt and good tipper"
Wilcox,Jack,,,12458,7/14/2017,very nice
O'Neil,Kasper,WY,82937,15499,3/7/2011,paid by certified check
Marks,Sopoline,CT,06778,4859,8/21/2014,"never paid, do not do any further business"
Kelly,Colorado,,,9899,6/3/2018,

Built Lists and Values Text File Schema Definition

Type=CONTROL,ID=1,SchemaEnclosureCharacter=22,Version=1.0.1.22,,,,,,,,,,,,,,,,,
Type=META,ID=2,Name=Smythee Estuary Importers - Sales Summary Text File Schema Definition,Annotation=This file had been prepared by Doug Jones to match the records given 12/30/2019,Version=1.0.0.1,FileType=DELIMITED,DelimiterCharacter=2C,EnclosureCharacter=22,EncloseWhen=NEEDED,CharacterEncoding=UTF-8,EndOfLine=NEWLINE,FieldIDMethod=HEADER,SchemaURL=https://www.smytheeestuaryimporters.com/schemas.html,OwnerName=James Smythee,OwnerEmail=james.smythee@smytheeestuaryimporters.com,OwnerPhone=123-555-1234,,,,,
Type=RECORD,ID=3,Name=Header Record,Annotation=This defines the header record,Position=1,ParentID=2,Required=YES,HasData=ALWAYS,MinimumAllowed=1,MaximumAllowed=1,KeyField=,ParentKeyField=,RecordIDPosition=,RecordIDValue=,RecordRow=1,Width=,IsHeader=YES,TrailingDelimiter=NO,,,
Type=RECORD,ID=4,Name=Data Record,Annotation=This defines the data records,Position=2,ParentID=2,Required=YES,HasData=ALWAYS,MinimumAllowed=1,MaximumAllowed=,KeyField=,ParentKeyField=,RecordIDPosition=,RecordIDValue=,RecordRow=,Width=,IsHeader=NO,TrailingDelimiter=NO,,,
Type=FIELD,ID=5,Name=Last Name Header,Annotation=,Position=1,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=9,MaximumLength=9,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^last_name$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=last_name
Type=FIELD,ID=6,Name=First Name Header,Annotation=,Position=2,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=10,MaximumLength=10,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^first_name$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=first_name
Type=FIELD,ID=7,Name=State Header,Annotation=,Position=3,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^state$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=state
Type=FIELD,ID=8,Name=ZIP Code Header,Annotation=,Position=4,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=8,MaximumLength=8,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^zip_code$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=zip_code
Type=FIELD,ID=9,Name=Price Header,Annotation=,Position=5,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^price$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=price
Type=FIELD,ID=10,Name=Date Header,Annotation=,Position=6,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=4,MaximumLength=4,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^date$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=date
Type=FIELD,ID=11,Name=Notes Header,Annotation=,Position=7,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^notes$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=notes
Type=FIELD,ID=12,Name=Last Name,Annotation=,Position=1,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=1,MaximumLength=50,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=O'Neil
Type=FIELD,ID=13,Name=First Name,Annotation=,Position=2,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=1,MaximumLength=50,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=Kasper
Type=FIELD,ID=14,Name=State,Annotation=,Position=3,ParentID=4,Required=YES,HasData=OPTIONAL,MinimumLength=2,MaximumLength=2,DataType=STRING,DateTimeFormat=,ListID=19,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=WY
Type=FIELD,ID=15,Name=ZIP Code,Annotation=,Position=4,ParentID=4,Required=YES,HasData=OPTIONAL,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^[0-9]{5}$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=82937
Type=FIELD,ID=16,Name=Price,Annotation=,Position=5,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=,MaximumLength=,DataType=NUMBER,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=1,NumericMaximumValue=99999999,Start=,Width=,Alignment=,FillCharacter=,Sample=15499
Type=FIELD,ID=17,Name=Date,Annotation=,Position=6,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=,MaximumLength=,DataType=DATE TIME,DateTimeFormat=M/d/yyyy,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=3/7/2011
Type=FIELD,ID=18,Name=Notes,Annotation=,Position=7,ParentID=4,Required=YES,HasData=OPTIONAL,MinimumLength=1,MaximumLength=255,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=paid by certified check
Type=LIST,ID=19,Name=Allowed States,Annotation=,Position=3,,,,,,,,,,,,,,,,
Type=VALUE,ID=20,Name=Connecticut,Annotation=,Position=1,ParentID=19,Value=CT,,,,,,,,,,,,,,
Type=VALUE,ID=21,Name=Georgia,Annotation=,Position=2,ParentID=19,Value=GA,,,,,,,,,,,,,,
Type=VALUE,ID=22,Name=Montana,Annotation=,Position=3,ParentID=19,Value=MT,,,,,,,,,,,,,,
Type=VALUE,ID=23,Name=Oklahoma,Annotation=,Position=4,ParentID=19,Value=OK,,,,,,,,,,,,,,
Type=VALUE,ID=24,Name=Vermont,Annotation=,Position=5,ParentID=19,Value=VT,,,,,,,,,,,,,,
Type=VALUE,ID=25,Name=Wyoming,Annotation=,Position=6,ParentID=19,Value=WY,,,,,,,,,,,,,,
Type=SUMMARY,ID=26,ControlCount=1,MetaCount=1,RecordCount=2,FieldCount=14,ListCount=1,ValueCount=6,ConditionCount=0,RuleCount=0,SummaryCount=1,TotalCount=26,,,,,,,,,

Steps To Build The Conditions Text File Schema Definition

  1. Open the Lists and Values Text File Schema Definition file in a text editor
    1. https://textfileschema.omegatower.net/schemas/tutorial_lists_and_values.tfsd
    2. Save it with a new file name
    3. Don't forget to save it frequently and often as you build the Text File Schema Definition
  2. Open the Text File Schema Definition template file in a text editor
    1. https://textfileschema.omegatower.net/schemas/tfsd_template.tfsd
    2. Copy the Condition Record and paste it in the new Lists and Values Text File Schema Definition file just before the Summary Record
    3. Copy the List Record and paste it in the new Lists and Values Text File Schema Definition file just before the Summary Record
    4. Copy the Value Record and paste it in the new Lists and Values Text File Schema Definition file just before the Summary Record, repeating twice
  3. Update the Condition Record, using its definition as a guide, to define the Condition

    1. Set ID to "26"
      It's the 26th record in the Schema Definition, so this is a logical choice for the ID.
    2. Set Name to "States and ZIP Codes Condition"
      Naming the condition will facilitate any discussions or other documentation.
    3. Set Position to "4"
      It's the fourth record belonging to its parent record: the Meta Record.
    4. Set Level to "FIELD"
      As this condition only involves fields in the Text File, this field is set appropriately.
    5. Set ConditionType to "PAIRED"
      Since the desired outcome is to ensure both fields in the Text File have data when either one has data, set this field appropriately
  4. Update the List Record, using its definition as a guide, to define the first allowed State

    1. Set ID to "27"
      It's the 27th record in the Schema Definition, so this is a logical choice for the ID.
    2. Set Name to "States and ZIP Codes List"
      Naming the list will facilitate any discussions or other documentation.
    3. Set Position to "5"
      It's the fifth record belonging to its parent record: the Meta Record.
  5. Update the first new Value Record, using its definition as a guide, to define the first FieldID used for the Condition
    1. Set ID to "28"
      It's the 28th record in the Schema Definition, so this is a logical choice for the ID.
    2. Set Name to "State FieldID"
      Naming the value will facilitate any discussions or other documentation.
    3. Set Position to "1"
      It's the first value belonging to its parent list: the "States and ZIP Codes List" List Record.
    4. Set ParentID to "27"
      The ID of its parent record, the "States and ZIP Codes List" List Record, goes here.
    5. Set Value to "14"
      The ID of the first field in the condition goes here.
  6. Update the second new Value Record, using its definition as a guide, to define the second FieldID used for the Condition
    1. Set ID to "29"
      It's the 29th record in the Schema Definition, so this is a logical choice for the ID.
    2. Set Name to "ZIP Code FieldID"
      Naming the value will facilitate any discussions or other documentation.
    3. Set Position to "2"
      It's the second value belonging to its parent list: the "States and ZIP Codes List" List Record.
    4. Set ParentID to "27"
      The ID of its parent record, the "States and ZIP Codes List" List Record, goes here.
    5. Set Value to "15"
      The ID of the second field in the condition goes here.
  7. Update the Summary Record, using its definition as a guide, to correct its information
    1. Set ID to "30"
      It's now the 30th record in the Schema Definition, so this is a logical choice for the ID.
    2. Set ListCount to "2"
      There are now two List Records in the Schema Definition, so change this to match.
    3. Set ValueCount to "8"
      There are now eight Value Records in the Schema Definition, so change this to match.
    4. Set ConditionCount to "1"
      There is now one Condition Record in the Schema Definition, so change this to match.
    5. Set TotalCount to "30"
      There are now 30 Records in the Schema Definition, so change this to match.
  8. Update the Condition Record "States and ZIP Codes Condition", currently ID=26, using its definition as a guide, to add the new List
    1. Set ListID to "27"

Built Conditions Text File Schema Definition

Type=CONTROL,ID=1,SchemaEnclosureCharacter=22,Version=1.0.1.22,,,,,,,,,,,,,,,,,
Type=META,ID=2,Name=Smythee Estuary Importers - Sales Summary Text File Schema Definition,Annotation=This file had been prepared by Doug Jones to match the records given 12/30/2019,Version=1.0.0.1,FileType=DELIMITED,DelimiterCharacter=2C,EnclosureCharacter=22,EncloseWhen=NEEDED,CharacterEncoding=UTF-8,EndOfLine=NEWLINE,FieldIDMethod=HEADER,SchemaURL=https://www.smytheeestuaryimporters.com/schemas.html,OwnerName=James Smythee,OwnerEmail=james.smythee@smytheeestuaryimporters.com,OwnerPhone=123-555-1234,,,,,
Type=RECORD,ID=3,Name=Header Record,Annotation=This defines the header record,Position=1,ParentID=2,Required=YES,HasData=ALWAYS,MinimumAllowed=1,MaximumAllowed=1,KeyField=,ParentKeyField=,RecordIDPosition=,RecordIDValue=,RecordRow=1,Width=,IsHeader=YES,TrailingDelimiter=NO,,,
Type=RECORD,ID=4,Name=Data Record,Annotation=This defines the data records,Position=2,ParentID=2,Required=YES,HasData=ALWAYS,MinimumAllowed=1,MaximumAllowed=,KeyField=,ParentKeyField=,RecordIDPosition=,RecordIDValue=,RecordRow=,Width=,IsHeader=NO,TrailingDelimiter=NO,,,
Type=FIELD,ID=5,Name=Last Name Header,Annotation=,Position=1,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=9,MaximumLength=9,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^last_name$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=last_name
Type=FIELD,ID=6,Name=First Name Header,Annotation=,Position=2,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=10,MaximumLength=10,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^first_name$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=first_name
Type=FIELD,ID=7,Name=State Header,Annotation=,Position=3,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^state$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=state
Type=FIELD,ID=8,Name=ZIP Code Header,Annotation=,Position=4,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=8,MaximumLength=8,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^zip_code$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=zip_code
Type=FIELD,ID=9,Name=Price Header,Annotation=,Position=5,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^price$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=price
Type=FIELD,ID=10,Name=Date Header,Annotation=,Position=6,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=4,MaximumLength=4,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^date$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=date
Type=FIELD,ID=11,Name=Notes Header,Annotation=,Position=7,ParentID=3,Required=YES,HasData=ALWAYS,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^notes$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=notes
Type=FIELD,ID=12,Name=Last Name,Annotation=,Position=1,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=1,MaximumLength=50,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=O'Neil
Type=FIELD,ID=13,Name=First Name,Annotation=,Position=2,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=1,MaximumLength=50,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=Kasper
Type=FIELD,ID=14,Name=State,Annotation=,Position=3,ParentID=4,Required=YES,HasData=OPTIONAL,MinimumLength=2,MaximumLength=2,DataType=STRING,DateTimeFormat=,ListID=19,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=WY
Type=FIELD,ID=15,Name=ZIP Code,Annotation=,Position=4,ParentID=4,Required=YES,HasData=OPTIONAL,MinimumLength=5,MaximumLength=5,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=^[0-9]{5}$,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=82937
Type=FIELD,ID=16,Name=Price,Annotation=,Position=5,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=,MaximumLength=,DataType=NUMBER,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=1,NumericMaximumValue=99999999,Start=,Width=,Alignment=,FillCharacter=,Sample=15499
Type=FIELD,ID=17,Name=Date,Annotation=,Position=6,ParentID=4,Required=YES,HasData=ALWAYS,MinimumLength=,MaximumLength=,DataType=DATE TIME,DateTimeFormat=M/d/yyyy,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=3/7/2011
Type=FIELD,ID=18,Name=Notes,Annotation=,Position=7,ParentID=4,Required=YES,HasData=OPTIONAL,MinimumLength=1,MaximumLength=255,DataType=STRING,DateTimeFormat=,ListID=,StringRegex=,NumericMinimumValue=,NumericMaximumValue=,Start=,Width=,Alignment=,FillCharacter=,Sample=paid by certified check
Type=LIST,ID=19,Name=Allowed States,Annotation=,Position=3,,,,,,,,,,,,,,,,
Type=VALUE,ID=20,Name=Connecticut,Annotation=,Position=1,ParentID=19,Value=CT,,,,,,,,,,,,,,
Type=VALUE,ID=21,Name=Georgia,Annotation=,Position=2,ParentID=19,Value=GA,,,,,,,,,,,,,,
Type=VALUE,ID=22,Name=Montana,Annotation=,Position=3,ParentID=19,Value=MT,,,,,,,,,,,,,,
Type=VALUE,ID=23,Name=Oklahoma,Annotation=,Position=4,ParentID=19,Value=OK,,,,,,,,,,,,,,
Type=VALUE,ID=24,Name=Vermont,Annotation=,Position=5,ParentID=19,Value=VT,,,,,,,,,,,,,,
Type=VALUE,ID=25,Name=Wyoming,Annotation=,Position=6,ParentID=19,Value=WY,,,,,,,,,,,,,,
Type=CONDITION,ID=26,Name=States and ZIP Codes Condition,Annotation=,Position=4,Level=FIELD,ConditionType=PAIRED,ListID=27,,,,,,,,,,,,,
Type=LIST,ID=27,Name=States and ZIP Codes List,Annotation=,Position=5,,,,,,,,,,,,,,,,
Type=VALUE,ID=28,Name=State FieldID,Annotation=,Position=1,ParentID=27,Value=14,,,,,,,,,,,,,,
Type=VALUE,ID=29,Name=ZIP Code FieldID,Annotation=,Position=2,ParentID=27,Value=15,,,,,,,,,,,,,,
Type=SUMMARY,ID=30,ControlCount=1,MetaCount=1,RecordCount=2,FieldCount=14,ListCount=2,ValueCount=8,ConditionCount=1,RuleCount=0,SummaryCount=1,TotalCount=30,,,,,,,,,
Back to top