This may seem trivial to some, but what is the best way to go for conversion purposes, from a text file into a GIS format. I was looking to use win32com and convert a txt file right into Access, but Esri does not support the .accdb format, so this does not solve my issue, unless win32com allows to go straight into a mdb. I was also thinking of the dbf format (Seems like a dated approach), or does it make sense to just use the insertcursor from a text file right into a file GB. I get a lot of txt files from management, and I am looking to just build a tool for myself or them to get something a bit more useful and streamline my own workflow. i don't really want to go into SQL Server or Postgress for simple operations.
Hi Ted
Could depend on how your .txt files are structured, but a .txt can be read by most tools that accept a table or table view as input. So you could feed it directly into tools like Make XY Event Layer or XY To Line. Or you could read in the file in Python and write out in your own flavor with a cursor.
-Dave
That was fast, so txt file can be read as a table, thats interesting, something to explore for sure. thanks David. I like the last idea at least for testing purposes at 10.1. So, regarding the structure, do the tools, handle comma delimited, and treat the top row as the column headings?
Yes.
Just to confirm myself, I created a little text file that contained this:
a,b,c,d
1,2,3,S
4,5,6,T
I used that as input to TableToTable and it spit out a table of 2 rows with 5 fields (OBJECTID, a, b, c, d)
-Dave
with open (r"C:\1GIS\Sales\ReplaceString\Sales2011.txt", "r+") as txtFile: data = txtFile.readline() print "*" * 530 print data change = data.replace("/ ", "_").replace("/", "_").replace(" ", "_") print change
r+ is for appending, how does rb work?
Ohhhh, you're not actually doing the .write() call, you're just reading. You may want to read from the file and output to a new one to be safe.
with open (r"C:\1GIS\Sales\ReplaceString\Sales2011.txt", "r+b") as txtFile: data = txtFile.readline() print "*" * 530 print data change = data.replace("/ ", "_").replace("/", "_").replace(" ", "_") print change txtFile.write (change) #txtFile.writelines(change)