I'm trying to delete white spaces and enter's from a list, which i need to import as coordinates. However this does not seem to work. giving the following error:
AttributeError: 'list' object has no attribute 'strip'
Currently i'm still looking into the removal of the spaces (first these have to be deleted, then the enter's will follow).
Does anyone has any suggestions why this does not work?
the code is as follow:
# Open a file
Bronbestand = open("D:\\Documents\\SkyDrive\\afstuderen\\99 EEM - Abaqus 6.11.2\\scripting\\testuitlezen4.txt", "r")
headerLine = Bronbestand.readline()
valueList = headerLine.split(",")
#valueList = valueList.replace(" ","")
xValueIndex = valueList.index("x")
yValueIndex = valueList.index("y")
#xValueIndex = xValueIndex.replace(" ","")
#yValueIndex = yValueIndex.replace(" ","")
coordList = []
for line in Bronbestand.readlines():
segmentedLine = line.split(",")
coordList.append([segmentedLine[xValueIndex], segmentedLine[yValueIndex]])
coordList2 = [x.strip(' ') for x in coordList]
print coordList2
Where the "Bronbestand" is the following:
id,x,y,
1, -1.24344945, 4.84291601
2, -2.40876842, 4.38153362
3, -3.42273545, 3.6448431
4, -4.22163963, 2.67913389
5, -4.7552824, 1.54508495
6, -4.99013376, -0.313952595
7, -4.7552824, -1.54508495
8, -4.22163963, -2.67913389
9, -3.42273545, -3.6448431
Thank you all in advance for the help!