How do I create a CSV file?

Records can be imported to any database from a CSV representation.

A CSV file is a text file. You can create it using a text editor (such as Notepad or WordPad) or a word processor, providing you save the document in text form. When Match-IT is installed a suitable text editor, called FoldIt, is placed in your ...\match_it\sys directory.

In most cases the CSV files will be automatically created by the software system that is providing the information to be imported. Consult the documentation of that system to find out how to do this.

For the purposes of this discussion there are two types of CSV File. Those produced by your ‘donor’ system and those produced by the Match-IT import filter. The ‘donor’ CSV files are processed by the import filters to produce Match-IT CSV files. The syntax of these is slightly different. For completeness, the syntax of both is given here.

The 'donor' CSV file syntax is:

DonorCSVFile        ::= { DonorCSVRecord }

DonorCSVRecord        ::= DonorCSVField { CSVSeparator DonorCSVField }

DonorCSVField        ::= QuotedField | NonQuotedField

QuotedField                ::= QuoteCharacter FieldText QuoteCharacter

NonQuotedField        ::= FieldText

QuoteCharacter        ::= any character defined by the Match-IT default

CSVSeparator        ::= any character defined by the Match-IT default

If a field is quoted, then quote or separator characters embedded in the field itself are ignored. Thus: “abc,def”,”ghi” is interpreted as two fields, one of ‘abc,def’ and another of ‘ghi’. Similarly: “abc”def”ghi”,”jkl” is considered to be two fields, one of ‘abc”def”ghi’ and another of ‘jkl’.

The Match-IT CSV file syntax is:

MatchITCSVFile        ::= MatchITFieldList { MatchITCSVRecord }

MatchITFieldList        ::= MatchITFileId ‘:’ MatchITFieldSpec { ‘,’ MatchITFieldSpec }

MatchITFIleId        ::= the three character mnemonic of the file the records are destined for

MatchITFieldSpec        ::= [ IgnoreField ] MatchITFieldName [ '[AS:' TypeName ']' ]

IgnoreField                ::= '!'

MatchITFieldName        ::= the name of a field in the file

TypeName                ::= this must match a logical type name, e.g. 'Material', 'Measure', etc.

MatchITCSVRecord        ::= MatchITCSVField { FieldSeparator MatchITCSVField }

MatchITCSVField        ::= MatchITCSVElement { ElementSeparator MatchITCSVElement }

MatchITCSVElement        ::= a string that represents a value in the Match-IT file system

ElementSeparator        ::= this is always a comma (,)

FieldSeparator        ::= any character defined by the Match-IT package separator default

If IgnoreField is present, the field spec is ignored and the corresponding column in the CSV records is also ignored, this is intended to quickly turn a field 'off'.

In a Match-IT CSV file, fields may be composed of several elements. For example, a customer contact is defined by the customer name followed by the contact name. The elements required for each Match-IT field are defined elsewhere.

The number of elements in the MatchITFieldSpec must match that expected for the LType involved. E.g. "Each,1" for a measure.

If the [AS:...] clause is present it overrides the natural type designation for the field and interprets the field elements as the type defined by TypeName. This is intended to be used where the natural type is ambiguous. E.g. a 'MatStep' and a 'PrcStep' are both MCB references but one is defined via an MCH and the other via an MCD. So for the mch:Step field (a [KEYOF:mcb]), a field spec of Step[AS:MatStep] would expect a string of the form 'MaterialName,StepName' to yield an MCB ref for a material method, and a field spec of Step[AS:PrcStep] would expect a string of the form 'ProcessName,StepName' to yield an MCB ref for a process method.

Note: Importing like this is a crude field-to-field copy. If  the data needs processing in any way, it's usually better to write a Lua script.