python - Errors with turning string into integer? -


okay i'm reading in these values, used type(value) figure out being read in strings. tried convert them integers. here have:

with open('sextractordata1488.csv') f:     #getting rid of title, aka unusable lines:     _ in xrange(15):         next(f)     line in f:         cols = line.split()         object_num = int(float(cols[0])) 

and received error:

valueerror: not convert string float: # 

i tried

int(cols[0]) 

and received error:

valueerror: invalid literal int() base 10: '#' 

why giving me #? read means of values text, they're not. they're numbers. gives me error every line, , every line number.

someone wanted me copy , paste sample of data, here without first 16 lines removed , ... indicate there many more columns of data there wasn't room:

     1  -7.9031   0.0364     13.69501    489.4349...      2  -6.5735   0.1097     13.69501    193.0220...      3  -6.4870   0.1184     13.69501    192.5962...      4  -7.6035   0.0462     13.69501    504.2180...      5  -7.4926   0.0506     13.69501    782.2051...      6  -7.6036   0.0462     13.69501    569.3883... 

sorry if there's easier way show that. i'm new site.

apparently problem in xrange function. put 15 when should have put 16, first line had letters in problem.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -