Select to view content in your preferred language

Text to GIS dbase Best Practices

1681
11
08-30-2011 03:42 PM
TedCronin
MVP Alum
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.
Tags (2)
0 Kudos
11 Replies
StevenCyphers
New Contributor
I actually have tried both:
txtFile.write (change)
#txtFile.writelines(change)

inside the with statement

The file is not getting updated.

So basically, I am doing:


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)


Hi Ted,

I haven't used the r+b flag, i shall give that one a whirl at some point. I have always read original.txt and write to new.txt followed by using os.remove() cleanup if there are intermediate steps ot text file i do not want to hang onto.

but i have smooshed a bit of text into csv. And i have always just passed the replaces back to the variable. e.g.

data = txtFile.readline()
while data:
    data = data.replace("/ ", "_").replace("/", "_").replace(" ", "_")
    outFile.write(data)
    data = txtFile.readline()

i think it might be the r+ flag might be the sticking point. i should go read the notes on it.
0 Kudos
TedCronin
MVP Alum
Hi Ted,

I haven't used the r+b flag, i shall give that one a whirl at some point. I have always read original.txt and write to new.txt followed by using os.remove() cleanup if there are intermediate steps ot text file i do not want to hang onto.

but i have smooshed a bit of text into csv. And i have always just passed the replaces back to the variable. e.g.

data = txtFile.readline()
while data:
    data = data.replace("/ ", "_").replace("/", "_").replace(" ", "_")
    outFile.write(data)
    data = txtFile.readline()

i think it might be the r+ flag might be the sticking point. i should go read the notes on it.


I will have to play with this a bit more, so cool, thanks for giving me an idea.
0 Kudos