ADO ConnectionString TextFile: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
Line 2: Line 2:
Text files files accessed via ADO will be read only. ADO does not have a driver that supports writing to or creating text files.
Text files files accessed via ADO will be read only. ADO does not have a driver that supports writing to or creating text files.


==Arguments==
=Arguments=
The Provider supports the following arguments:
The Provider supports the following arguments:


Line 17: Line 17:
| Custom Delimited || Fields in the file are separated by some character other than a tab or a comma (with one exception: you can't use the double-quote as a delimiter). For example, the asterisk is used as the delimiter || Format=Delimited(*) || FMT=Delimited(*)
| Custom Delimited || Fields in the file are separated by some character other than a tab or a comma (with one exception: you can't use the double-quote as a delimiter). For example, the asterisk is used as the delimiter || Format=Delimited(*) || FMT=Delimited(*)
|-
|-
| Fixed-Length || Fields in a file take up a specific number of characters. If a value is too long, "extra" characters are chopped off the end. If a value is too short, blank spaces are appended to it to make it fill out the requisite number of characters. <br> The columns (fields) of the file need to be defined in a Schema file. || Format=FixedLength || FMT=FixedLength
| Fixed-Length || Fields in a file take up a specific number of characters. If a value is too long, "extra" characters are chopped off the end. If a value is too short, blank spaces are appended to it to make it fill out the requisite number of characters. <br> The columns (fields) of the file need to be defined in a file named Schema.ini. || Format=FixedLength || FMT=FixedLength
|}
|}


Line 23: Line 23:
:Specifying HDR=YES means that the test file contains a header row. A header row simply means that the first row in the text file is a list of fields, with all subsequent rows containing the actual data.
:Specifying HDR=YES means that the test file contains a header row. A header row simply means that the first row in the text file is a list of fields, with all subsequent rows containing the actual data.
[[Category:ADO]]
[[Category:ADO]]
= Schema.ini=
Schema.ini is simply a text file that tells ADO how to deal with your data file(s). This, by the way, is optional only when using a delimited file; if you have a fixed-length text file, you must use a Schema.ini file. In this file, you define the separator to be used (optional) and define the columns (fields) using syntax similar to this:
Coln=Fieldname Datatype <additional information>
Example:
Col1=FirstName Text Width 7
Col2=LastName Text Width 10
Col3=ID Text Integer 3
After you create the Schema.ini file, make sure you indicate in your script that the file does not use a header row. To do that, just set the HDR parameter to No.
A Separator.ini can hold information for many files. Hence you need to start each definition by the filename enclosed in square brackets e.g.:
[File_1.txt]
Format=CSVDelimited
[File_2.txt]
Format=TabDelimited
'''Important:''' Schema.ini must be in the same folder as your text file.
== Separator ==
With a delimited file, this often involves nothing more than telling ADO what the delimiter is:
[MyLog.txt]
Format=TabDelimited
== Data Types ==
You can use the following data types:
* Text
* Short
* Long
* Currency
* Single
* Double
* DateTime
* Memo

Revision as of 11:52, 5 January 2014

This page is still a work in progress.

Text files files accessed via ADO will be read only. ADO does not have a driver that supports writing to or creating text files.

Arguments

The Provider supports the following arguments:

FMT
This argument tells ADO which delimiter is used for the file. Although the comma is probably the most widely-used delimiter for text files, it's not the only one. Another popular delimiter is the TAB.
Format Description Schema.ini Syntax Connection String Syntax
Tab Delimited Fields in the file are separated by tabs Format=TabDelimited FMT=TabDelimited
CSV Delimited Fields in the file are separated by commas (note that there should not be a space between the comma and the start of the next field name or value) Format=CSVDelimited FMT=CSVDelimited
Custom Delimited Fields in the file are separated by some character other than a tab or a comma (with one exception: you can't use the double-quote as a delimiter). For example, the asterisk is used as the delimiter Format=Delimited(*) FMT=Delimited(*)
Fixed-Length Fields in a file take up a specific number of characters. If a value is too long, "extra" characters are chopped off the end. If a value is too short, blank spaces are appended to it to make it fill out the requisite number of characters.
The columns (fields) of the file need to be defined in a file named Schema.ini.
Format=FixedLength FMT=FixedLength
HDR
Specifying HDR=YES means that the test file contains a header row. A header row simply means that the first row in the text file is a list of fields, with all subsequent rows containing the actual data.

Schema.ini

Schema.ini is simply a text file that tells ADO how to deal with your data file(s). This, by the way, is optional only when using a delimited file; if you have a fixed-length text file, you must use a Schema.ini file. In this file, you define the separator to be used (optional) and define the columns (fields) using syntax similar to this:

Coln=Fieldname Datatype <additional information>

Example:

Col1=FirstName Text Width 7
Col2=LastName Text Width 10
Col3=ID Text Integer 3

After you create the Schema.ini file, make sure you indicate in your script that the file does not use a header row. To do that, just set the HDR parameter to No.

A Separator.ini can hold information for many files. Hence you need to start each definition by the filename enclosed in square brackets e.g.:

[File_1.txt]
Format=CSVDelimited
[File_2.txt]
Format=TabDelimited

Important: Schema.ini must be in the same folder as your text file.

Separator

With a delimited file, this often involves nothing more than telling ADO what the delimiter is:

[MyLog.txt]
Format=TabDelimited

Data Types

You can use the following data types:

  • Text
  • Short
  • Long
  • Currency
  • Single
  • Double
  • DateTime
  • Memo