I have a little piece of code which is running well, however I am struggling to determine a way of outputting it into a .txt file. Here is the code:
with open("Coord") as f:
line=f.readline()
for line in f:
coords=map(float,line.split(" "))
if poly.contains(Point(coords[0],coords[1])):
print line
The print command works and displays what I need in the terminal, however I just can't manage to find a way to save this yet. Here is what I have tried so far:
np.savetxt('inside.txt', np.vstack((line.str())).T)
AttributeError: 'str' object has no attribute 'str'
np.savetxt('inside.txt', line)
IndexError: tuple index out of range
np.savetxt('inside.txt', np.transpose([line])
TypeError: float argument required, not numpy.string_
np.savetxt('inside.txt', line, delimiter=" ", fmt="%s")
IndexError: tuple index out of range
I am still quite inexperienced at python and code in general and was hoping somebody could explain the correct formatting to be used here. Thanks in advance.