Hello, I could use a spot of help today.
I am very new to python (n00b) and I have a rather specific Issue I am trying to resolve.
This problem can be solved using ArcGIS (for those who know it) I simply desire to know more about python so I want to solve it using python.
Problem: I have a data set that has some QA/QC issues that I am trying to locate. The data has an X and Y location value an ID value and an Elevation value. I have organized the data into a .csv file. I have successfully got the file to read in using the csv module. I essentially need to compare each Item in a list to every other item in the list. If there is a discrepancy I want that Item wrote to a new file. I ideally wish this program to run on a data set approx 60,000 entries.
I cannot get the program to Iterate through the list in the manner I desire so I could use some pointers on how logically that can be done. I also cannot get the output file to have more then 1 line of output.
Here is my code so far.
#----------------------------------------------------------------------------------
#This program will asses elevation in the following way. The user will determine the
#file path, then the user will also determine the buffer area and a limit to the
#differnece in elevation. Then the program will read, and assess
#the elevations for that buffer distance around each point. The end result is
#a file that contains the suspect entries.
#--------------------------------------------------------
#Import Libraries
#---------------------------------------------------------
import string
import math
import fileinput
import os
import anydbm
import sys
import csv
#---------------------------------------------
print "Hello USER! Please enter the filepath of the database you wish to check!"
print "REMEMBER USER! THE FILE MUST BE A COMMA DELIMITED .csv OR I WILL FREAK OUT"
filename = raw_input(">>>")
print "enter the size of the buffer you want (We are Using the Bottom of the well as the coordinate)"
pointbuff = raw_input(">>>")
pointbuff= float(pointbuff)
print "enter the ammount of elevation tolerance (in feet)"
elevation = raw_input(">>>")
print '......Working'
elevation = float(elevation)
temp = list()
test = list()
x1 = float()
x2 = float()
y1 = float()
y2 = float()
elev1 = float()
elev2= float()
count = int()
count = 0
#--------------------------------------------------------
#Test and export data function
#---------------------------------------------------------
def tester(x=float(),y = float(),elev = int(), g=list()):
read1 = csv.reader(open(filename, 'rb'))
for row in read1:
test = row
x2 = test[1]
if x2 == "":
x2 = 0
else:
x2 = float(x2)
y2 = test[2]
if y2 == "":
y2 = 0
else:
y2= float(y2)
elev2 = test[3]
if elev2 == "":
elev2 = 0
else:
elev2 = float(elev2)
#test if other point is in buffer
if x1 <= (x2 + pointbuff) or x1 >= (x2 - pointbuff) and y1 <= (y2 + pointbuff) or y1 >= (y2 - pointbuff):
if ((abs(elev1)) - (abs(elev2))) >= elevation:
f = open("G:\TESTOUTPUT.txt", 'w')
A = g
A = str(A)
test = str(test)
print A
f.write(A)
f.write('\n')
f.close()
def readit():
read = csv.reader(open(filename, 'rb'))
for row in read:
temp = row
x1 = temp[1]
if x1 == "":
x1 = 0
else:
x1 = float(x1)
y1 = temp[2]
if y1 == "":
y1 = 0
else:
y1 = float(y1)
elev1 = temp[3]
if elev1 == "":
elev1 = 0
else:
elev1 = float(elev1)
tester(x1,y1,elev1,temp)
readit()
print 'DONE!'
here is some sample data I am using
30952 594635.24 200621.13 0
22500 598647.51 170513.26 -2191
31634 603679.17 171486.24 -2255
22734 606320.46 177526.04 -2459
22842 605912.11 177952.72 -2481
44528 688937.27 202291.1 -2780
44528 688937.27 202291.1 -2943
28509 613899.93 162957.46 -2041
44528 688937.27 202291.1 -2921
59268 594188.52 200371.53 -2971
59268 594188.52 200371.53 -2969
58687 593467.84 199357.6 -2937
58687 593467.84 199357.6 -2927
40672 592204.28 200947.08 -2961
40672 592204.28 200947.08 -2960
1111111 592204.28 202291.1 0
I appologize for the quality of the code but as I said before Im very new to this
Many thanks,