Hello All,<br><br>I have a .csv file that I created by copying and pasting a list of all the players in the NBA with their respective teams and positions (<a href="http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO!">http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO!</a>). Unfortunately, when I do this I have no choice but to include a single leading whitespace character for each name. I'd like to compare this list of names to another list (also in .csv format but in a different file) using a simple Python script, but in order to do that I need to strip the leading whitespace from all of the names or none of them will match the names in the second list. However, when I try to do this as follows:<br>
<br>positions = open('/home/guillaume/Documents/playerpos.csv')<br><br>for line in positions:<br> info = line.split(',')<br> name = info[0]<br> name = name.strip()<br> print name #to examine the effect of name.strip()<br>
<br>I keep getting all of the names with the leading whitespace character NOT removed (for example: " Jeff Adrien". Why is this happening?<br><br>The following is a sample of the .csv file (the one I'm trying to remove the whitespace from) opened in gedit, the built-in Ubuntu text editor:<br>
<br> Jeff Adrien,SF,Houston Rockets<br> Arron Afflalo,SG,Denver Nuggets<br> Maurice Ager,GF,Minnesota Timberwolves<br> Blake Ahearn,PG,Los Angeles Clippers<br> Alexis Ajinca,FC,Toronto Raptors<br> Solomon Alabi,C,Toronto Raptors<br>
Cole Aldrich,C,Oklahoma City Thunder<br> LaMarcus Aldridge,FC,Portland Trail Blazers<br> Joe Alexander,SF,New Orleans Hornets<br> Lavoy Allen,FC,Philadelphia 76ers<br> Malik Allen,FC,Orlando Magic<br> Ray Allen,SG,Boston Celtics<br>
Tony Allen,GF,Memphis Grizzlies<br> Lance Allred,C,Indiana Pacers<br> Rafer Alston,PG,Miami Heat<br><br>Any help with this seemingly simple but maddening issue would be much appreciated.<br><br>thanks,<br>Guillaume<br><br>
<br><br>