Make XY Event Layer - need to convert to tab delimited csv file?

2281
4
03-03-2011 12:06 AM
LeeMusto
New Contributor
I have a very large csv file (too large to load in excel). If you take a section of the data and load it in excel, strings all load into one column, seperated by spaces. I need to create XY Event Layers from this csv and it appears for this to work that the csv needs to be tab delimited. I've tried to write a Python script replacing spaces with '\t' or using the csv module but cannot get it to work - my scripting knowledge is limited. Does anyone have a script to do this or can point me in the right direction? Any help would be much appreciated.
Tags (2)
0 Kudos
4 Replies
NealaGriffin
New Contributor
Do you have MS Access?  Access can handle much larger files then Excel.
0 Kudos
LeeMusto
New Contributor
No, I am afraid not. I know I can split the original files into parts to fit into excel, but I am going to have to do this a lot, so a script would be really useful. Thanks anyway.
0 Kudos
FrankVignati
Occasional Contributor II
the create xy event layer tool will work with csv files that are comma delimitted
but if you still want to convert them to tabs you can use a program named textpad that can be downloaded for free from the web
0 Kudos
KimOllivier
Occasional Contributor III
The best way to load CSV files is to define the schema in schema.ini in the same folder. This is by the Microsoft Text File driver that many Windows applications use including ArcGIS. It has no limits on file sizes and many other benefits. You can define the field separator, rename the field names, set fields types and text widths. If the first row has field names you can use them, skip them or rename them. It is very flexible and fast.

I have only recently discovered how useful the schema.ini definition can be. It saves having to write a Python script to parse and load the data into a table. You can just add the CSV file and export it to a geodatabase so you can edit and use it.
http://webhelp.esri.com/ARCGISDESKTOP/9.3/index.cfm?TopicName=Accessing_delimited_text_file_data
If you are going to create an XY event table, be aware that this is in memory and may be very slow converting it to a featureclass, or it may even fail. For very large files it may still be better to use an insertCursor to write a point featureclass directly in Python.
0 Kudos