title: python : ValueError: invalid literal for int() with base 10: ' '
body: <p>I have a text file which contains entry like</p>
  
  <pre><code>70154::308933::3
  UserId::ProductId::Score
  </code></pre>
  
  <p>I wrote this program to read:
  (Sorry the indendetion is bit messed up here)</p>
  
  <pre><code>def generateSyntheticData(fileName):
   dataDict = {}
   # rowDict = []
   innerDict = {}
  
  
   try:
      # for key in range(5):
      # count = 0
      myFile = open(fileName)
      c = 0
          #del innerDict[0:len(innerDict)]
  
      for line in myFile:
          c += 1
          #line = str(line)
          n = len(line)
          #print 'n: ',n
          if n is not 1:
         # if c%100 ==0: print "%d: "%c, " entries read so far"
         # words = line.replace(' ','_')
              words = line.replace('::',' ')
  
              words = words.strip().split()
  
  
              #print 'userid: ', words[0]
              userId = int( words[0]) # i get error here
              movieId = int (words[1])
              rating =float( words[2])
              print "userId: ", userId, " productId: ", movieId," :rating: ", rating
              #print words
              #words = words.replace('_', ' ')
              innerDict = dataDict.setdefault(userId,{})
              innerDict[movieId] = rating
              dataDict[userId] = (innerDict)
              innerDict = {}
  except IOError as (errno,strerror):
      print "I/O error({0}) :{1} ".format(errno,strerror)
  
  finally:
      myFile.close() 
  print "total ratings read from file",fileName," :%d " %c
  return dataDict
  </code></pre>
  
  <p>But i get the error: </p>
  
  <pre><code>ValueError: invalid literal for int() with base 10: ''
  </code></pre>
  
  <p>Funny thing is, it is working just fine reading the same format data from other file..
  Actually while posting this question, I noticed something weird..
  The entry 70154::308933::3
  each number has a space.in between like 7 space 0 space 1 space 5 space 4 space :: space 3...
  BUt the text file looks fine..:( on copy pasting only it shows this nature..
  Anyways.. but any clue whats going on.
  Thanks</p>