[Tutor] How do I go from a textFile.txt to a list [] AND from a textFile.txt to a dictionary of dictionaries?

Gregory Lund gnj091405 at gmail.com
Mon Jul 23 00:33:19 CEST 2012


Only my second try to post to this list.
This is a dumb question with a simple (I presume) solution...
but...
how do I take a txt file with semicolon separated values and create a
dictionary and a list?
( in 2.6 because I'm working with ArcGIS.)

text file is as follows: (saved as text_data.txt) (it's looooonger,
this is just a sample)

ObjID;Xval;Yval;LineID;PolyID
0;1279027.0;246427.9375;0;1
1;1279069.625;246433.234375;0;1
2;1279091.0;246435.046875;1;1
3;1279112.5;246436.3125;1;1
4;1279134.0;246437.0;2;1
5;1279176.875;246436.71875;2;1
6;1279198.375;246435.734375;3;1
7;1279219.75;246434.1875;3;1

I'd like to create a list from said text data...
and a dictionary of dictionaries from said data.

Eventually I will create a point, line and polygon shapefiles from this file.
With the data above, it would be an 8 point pnt file, a 3 line line
file and 1 polygon. (point 7 connecting back to point 0)

Right now, I'm just trying to get started by creating a list and a
dictionary (to see which I want to use when creating my shapefiles.)

And, I need to do it in 2.6 because I'm working with ArcGIS.

Thanks in advance for your thoughts?


More information about the Tutor mailing list