PROBLEM

Load date fields into INFO files using INFO GET command with COPY ASCII options

Solution or Workaround

When reading in date fields with GET COPY ASCII, the date '12/04/95' comes out looking like '4//95/12/0', even though the date format set by the INFO DFMT command is MDY/. How can this be fixed?

Answer:

The INFO GET command with the ASCII option reads records in the format in which they are stored, not in the INFO display format. The INFO DFMT (date format) command specifies the output or display format.

INFO stores dates in the YYYYMMDD format. The separator character in the date display format ( \, /, or -) is not stored in the date field. The INFO GET command expects the date to be in the YYYYMMDD format. The problem is the input text file date field is in a fixed format such as MM/DD/YY.

Rather than editing the text file to get the date in the proper format, you can first read in the date as a character field and then use the INFO REDEFINE and CONCATENATE commands to populate a newly added INFO date item.

1) Use the INFO DEFINE command to create an empty INFO file with the date field defined as a character item. If the text field is in MM/DD/YY formate define the INFO item as 8,8,C.

2) Use the INFO GET command with the COPY ASCII option to load the text file into the just defined INFO file.

3) Use the ARC ADDITEM command to add a date (D type) item to the INFO file.

4) Use the INFO REDEFINE command to create three items (M, D and Y) from the character field. These items provide access to the month, day and year values. The REDEFINE is done as follows.

Code:
ARC: INFO
ENTER USER NAME: ARC
SELECT DATE.DAT
ENTER COMMAND >ITEMS
DATAFILE NAME: DATE.DAT 12/10/1994
2 ITEMS: STARTING IN POSITION 1
COL ITEM NAME WDTH OPUT TYP N.DEC ALTERNATE NAME
1 DATE_C 8 8 C -
9 DATE 8 10 D -

ENTER COMMAND >LIST DATE_C,DATE
$RECNO DATE_C DATE
1 12/04/65 / /
2 09/30/55 / /
3 01/01/95 / /
4 12/10/94 / /

ENTER COMMAND >REDEFINE
ENTER DATAFILE DEFINITION
ITEM STARTING COLUMN>1,M,2,2,C
ITEM STARTING COLUMN>4,D,2,2,C
ITEM STARTING COLUMN>7,Y,2,2,C
ITEM STARTING COLUMN>


5) Use the INFO ITEMS and LIST command to check the redefined items.

Code:
ENTER COMMAND >ITEMS
DATAFILE NAME: DATE.DAT
2 ITEMS: STARTING IN POSITION 1
COL ITEM NAME WDTH OPUT TYP N.DEC ALTERNATE NAME
1 DATE_C 8 8 C -
9 DATE 8 10 D -
** REDEFINED ITEMS **
1 M 2 2 C -
4 D 2 2 C -
7 Y 2 2 C -
ENTER COMMAND >LIST DATE_C,DATE,M,D,Y
$RECNO DATE_C DATE M D Y
1 12/04/65 / / 12 04 65
2 09/30/55 / / 09 30 55
3 01/01/95 / / 01 01 95
4 12/10/94 / / 12 10 94


6) Use the INFO CONCATINATE command to populate the DATE item. You must enclose the first two digits of the year in single quotes to store the date as required by the INFO DATE storage format YYYYMMDD. (If your dates are in multiple centuries, you will have to use the INFO ASELECT, NSELECT and/or RESELECT commands prior to each CONCATINATE command.)

Code:
ENTER COMMAND >CONCAT DATE FROM '19',Y,M,D
ENTER COMMAND >LIST DATE_C,DATE,M,D,Y
$RECNO DATE_C DATE M D Y
1 12/04/65 12/04/1965 12 04 65
2 09/30/55 09/30/1955 09 30 55
3 01/01/95 01/01/1995 01 01 95
4 12/10/94 12/10/1994 12 10 94


7) Use the ARC DROPITEM command to get rid of the character item and the redefined items.

Code:
ENTER COMMAND >QUIT STOP

Arc: USAGE DROPITEM
Usage: DROPITEM <in_info_file> <out_info_file> {item...item}

Arc: DROPITEM DATE.DAT DATE.DAT DATE_C M D Y

Arc: list date.dat
Record DATE
1 12/04/1965
2 09/30/1955
3 01/01/1995
4 12/10/1994


Article ID:000001319

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic