AnsweredAssumed Answered

Create variable with Cursor and write it in a text file with Python

Question asked by kostas_ptr88 on May 28, 2015
Latest reply on May 28, 2015 by curtvprice

Hi, i am trying to create three variables from a table and write them in a text file with Python. These variables are values from the first row of three fields. I tried it with Search Cursor but i can get only the first variable, i don't know why. Next i am trying to do the same with a folder of polylines taking the first row of 2 fields using the same text i created above but unsuccesfully. Any suggestion would be great. Thanks a lot. This is my code:


import arcpy
import os
from arcpy import env

arcpy.env.workspace = "c:/Win/Sik"
input = "s3s2c10"
fields = ['X', 'Y', 'MOSAIC']

outFile = open("c:/Win/Sik/moon.text", "w")
with arcpy.da.SearchCursor(input, fields, 'OID = 1') as cursor:
    X = row[0]
    Y = row[1]
    IPSOS = row[2]

outFile.write('x is '+str(X)+'meters,'\n' Y is'+str(Y)+'and '\n' ipsos is'+str(IPSOS))

import arcpy
import os
arcpy.env.workspace = "c:Win/Sik/True
outFile = open("c:/Win/Sik/moon.text", "w")
featureclasses = arcpy.ListFeatureClasses("Truelines", "Polyline", "")
for fc in featureclasses:
    TIME = row[0]
    DISTANCE = row[1] 
outFile.write( '\n''\n' 'TIME is '+str(TIME)+'meters,'\n' and DISTANCE is'+str(DISTANCE)+'meters'