Wednesday, November 10, 2010

Automatically Generate KML Files from CSV file

# Import System Modules

import sys, string, os, csv

# Enter the input and output file names here

inputFileName="PROJECT.csv"
outputFileName="PROJ.kml"

inFile=open(inputFileName)
outFile=open(outputFileName,'a')

# Enter the total number of records here
numobs = 12

header =""+"\n"+\
""+"\n"+\
""+"\n"+\
"Spatial Distribution of Students "+"\n"

# Read in the stand attributes file one line at a time

outFile.write(str(header))

for obs in range(numobs):
readline=inFile.readline()

# Select the variables
currow=readline.split(",")
student=currow[0]
year=currow[1]
rslat=currow[2]
rslong=currow[3]
advisor=currow[4]
studyarea=currow[5]

outFile.write(""+"\n"+\
""+student+""+"\n"+\
""+"Location: "+studyarea +","+"Thesis Year: "+year+","+"Thesis Advisor: "+advisor +""+"\n"+\
""+"\n"+\
""+rslong+","+rslat+"13"+""+"\n"+\
"
"+"\n"+\
"
"+"\n")
#print studentInfo
#outFile.write(str(studentInfo))

footer="
"+"\n"+\
"
"

outFile.write(str(footer))

inFile.close()
outFile.close()


0 comments :

Post a Comment

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me