0

I'm parsing hand histories from Pokerstars.

I'm getting the following error when I try to parse the hands directly from the Pokerstars file:

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

What is really strange is that I'm totally successful parsing the same content with hundreds of hands if I have copied/pasted the text from the pokerstars text file into Textmate and having saved the Textmate .txt file.

I'm thinking it might have to do with the line breaks or the utf-8 encoding which Textmate defaults to but I don't have enough understanding of these issues to fix the problem.

EDIT

I have now determined that the Pokerstars file is UTF-8 encoded. My next suspect is the end of line character issue.

Any idea on how to check with EOL characters are used in file? and in changing those to a new one?

Any other ideas? Something I might be missing?

allesklar
  • 9,506
  • 6
  • 36
  • 53

1 Answers1

4

I suspect the cause of the problem is BOM, take a look for example here:

http://naturalcode.wordpress.com/2008/08/30/ruby-19-and-unicode-the-bom-will-fuck-your-shit-up/

How to avoid tripping over UTF-8 BOM when reading files

and google further if that particular answer doesn't help.

Community
  • 1
  • 1
Mladen Jablanović
  • 43,461
  • 10
  • 90
  • 113
  • Wow. I had no clue of this. Thanks a lot Mladen. Gave you a thumbs up and a 'good answer'. That's the least I can do. For anyone interested I removed the BOM with a regular expression: line.gsub!("\xEF\xBB\xBF", '') – allesklar Dec 10 '10 at 15:19