ArcGIS 10.1 schema.ini file causes arcpy.CopyRows_management to fail

5008
4
Jump to solution
08-17-2012 10:38 AM
DDArnett
New Contributor II
I've had this python program working for a while where it pulls in a tab delimited text file and creates a file geodatabase table, using arcpy.CopyRows_management tool. The schema.ini file was used to set up the fields. When we upgraded to 10.1 I now get the error that the text file is not available or not the right type. I renamed the schema.ini file to something else and ran it again and there were no errors, but the table created did not have the right schema. The Help files state that although the schema.ini file is not needed it will still honor them.

Is this a bug or do I need to do this another way?
Tags (2)
1 Solution

Accepted Solutions
ChrisFox3
Occasional Contributor III
We are using a new engine for reading and writing to text files at 10.1, however we should still honor schema.ini files. It would be helpful to get a sample of your text file and the schema.ini to test the issue. In addition, i would recommend just running the GP tool from Desktop to take python out of the equation, the problem will likely still be reproducible.

View solution in original post

0 Kudos
4 Replies
curtvprice
MVP Esteemed Contributor
The 10.1 help
'>Adding an ASCII or text file table
says:

There is one instance in which a schema.ini file will be created by ArcGIS when opening a delimited text file: when the format for a certain field cannot be reliably determined. In this case, a schema.ini file will be created containing the presumed format of the field.


Could you post the first few lines of your text file? It looks like your particular file may be hard to interpret. You may have to re-write your schema.ini code to make it ingest properly. (This doesn't explain why it worked okay in 10.0 though.)
0 Kudos
ChrisFox3
Occasional Contributor III
We are using a new engine for reading and writing to text files at 10.1, however we should still honor schema.ini files. It would be helpful to get a sample of your text file and the schema.ini to test the issue. In addition, i would recommend just running the GP tool from Desktop to take python out of the equation, the problem will likely still be reproducible.
0 Kudos
JohnSemanchik
New Contributor II

Hi Chris Fox and Curtis Price​ ,

I have a similar issue, but when I use Table to Table (Conversion) my custom Schema.ini file is overwritten by the tool.  So if I try to force a field to be a specific type the tool deletes my changes and makes it's own file reverting back to the incorrect field types.  

I would prefer to hard code each field in the Schema.ini file as long as ArcGIS doesn't overwrite it.  Is there a way to lock the file down? 

Thanks,

John S.

System:

Windows 7

ArcGIS 10.1

Example Schema.ini:

[AOIs.csv]

Col1=Facility_Name Text Width 20

Col2=Date Date

Col3=Leader Text Width 50

Col4=Occurrence Text Width 35

Col5=Nature_of_AOI Text Width 35

Col6=Mapsite Text Width 150

Col7=Distance Text Width 25

Col8=Start_Point Text Width 20

Col9=End_Point Text Width 20

Col10=Total_Length Text Width 20

Col11=Starts_in Text Width 5

Col12=Comment Text Width 255

Example input CSV/Text:

Facility_Name,Date,Leader,Occurrence,Nature_of_AOI,Mapsite,Distance,Start_Point,End_Point,Total_Length,Starts_in,Comment

Place #1,2/1/2015 00:00,"Appleseed, Johnny",Daily,AOI A,"Site-1",376 Upstream,"012345, 0123456",,,No,At the Termination Point.

Place #2,2/2/2015 00:00,"Wayne, Bruce",Daily,AOI B,"Site-2",376 Upstream,"012345, 0123456","012345, 0123456",,No,At the Termination Point.

Place #3,2/3/2015 00:00,"Kent, Clark",Daily,AOI C,"Site-3",376 Upstream,"012345, 0123456",,,No,At the Termination Point.

0 Kudos
DDArnett
New Contributor II
It is working now. I needed to remove spaces around the '=', and then make sure that all column headings matched both in name and type.

Thanks
0 Kudos