Aha, maybe I figured out how to do it:
data = open("Test.csv" , "r")
print data.read()
but now I get this error:
Traceback (most recent call last):
File "/home/katharina/Desktop/Test.py", line 14, in <module>
dataLines = data.split("\n" )
AttributeError: 'file' object has no attribute 'split'
and if I uncomment the dataLines line...
User Profile
Collapse
-
Another question (sry...): If I import my csv file I get the fallowing structure:
['15', 'A', '50']
['10', 'A', '50']
['12', 'B', '30']
['10', 'C', '30']
['5', 'D', '50']
['10', 'D', '50']
How do you import your csv file without listing each row separately? I don“t seem to be able to figure out what I am doing wrong...Leave a comment:
-
I just copied your code and it works perfectly! Thank you so much!! I will try to understand what you did and maybe I can get back to you in case I do not understand something. Thanks!:)Leave a comment:
-
ok but with this solution I get several output for Polygon A and D. I am interested in summarizing the wooden Areas for each Polygon which has the same name. For Polygon A for example this would be 15+20/50. Is the quickest way to sum up the outputs or to do this step beforehand? Thanks a lot!!Leave a comment:
-
no, there are arcpy tools which you can call and as I understand they simplify the steps. But the problem is that some of them take very long to run. This website shows me how to read a csv file (https://docs.python.org/2/library/csv.html) and I managed to do that but how can I group the variables? Is there a function?Leave a comment:
-
Python csv calculate percentage by group
I have a table (csv file) with three columns:
Wood [m2] Polygon Area [m2]
15 A 50
10 A 50
12 B 30
10 C 30
05 D 50
10 D 50
My aim is to calculate the percentage of wood for each Polygon. I want to print this result into a new csv table:
Polygon Percentage of Wood (%)...
No activity results to display
Show More
Leave a comment: