# Odd CSV behavior

**URL:** <https://www.ruby-forum.com/t/odd-csv-behavior/144904>\
**Category:** Ruby\
**Created:** [August 4, 2008, 8:30am UTC](https://www.ruby-forum.com/t/odd-csv-behavior/144904 "2008-08-04T08:30:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![binkly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@binkly](https://www.ruby-forum.com/u/binkly)\
**Post date:** [August 4, 2008, 8:30am UTC](https://www.ruby-forum.com/t/odd-csv-behavior/144904/1 "2008-08-04T08:30:57Z")

</div>

Hello All,

I’m hoping someone out there can help me troubleshoot a strange problem  
that I’m experiencing with CSV files.

I download a file, in CSV format, from a website and when I try to parse  
with CSV and Faster CSV I get the following error.

/usr/local/lib/ruby/1.8/csv.rb:639:in `get_row': CSV::IllegalFormatError (CSV::IllegalFormatError) from /usr/local/lib/ruby/1.8/csv.rb:556:in`each’  
from /usr/local/lib/ruby/1.8/csv.rb:531:in `parse' from /usr/local/lib/ruby/1.8/csv.rb:311:in`open\_reader’  
from /usr/local/lib/ruby/1.8/csv.rb:85:in `open’

But if I open the CSV file in TextMate, select all of the contents,  
paste and save that content into a new CSV file, created with TextMate,  
the CSV parser can process it just fine.

Anyone have any idea about what might be causing this?

Thanks,

binh

---

<div class="post-metadata">

**Author:** ![binkly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@binkly](https://www.ruby-forum.com/u/binkly)\
**Post date:** [August 4, 2008, 9:19am UTC](https://www.ruby-forum.com/t/odd-csv-behavior/144904/2 "2008-08-04T09:19:47Z")

</div>

I think the csv file you have must be corrupted .  
Check out with the file.  
Kranthi.

---

<div class="post-metadata">

**Author:** ![binkly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@binkly](https://www.ruby-forum.com/u/binkly)\
**Post date:** [August 4, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/odd-csv-behavior/144904/3 "2008-08-04T21:45:29Z")

</div>

On Aug 3, 2008, at 23:29 , Binh Ly wrote:

> But if I open the CSV file in TextMate, select all of the contents,  
> paste and save that content into a new CSV file, created with  
> TextMate,  
> the CSV parser can process it just fine.

My guess is end of line format for the next file. Maybe you’re reading  
the whole file in as a single line and the EOL char is confusing CSV.  
TextMate could be reformatting it when you save it out.

---

<div class="post-metadata">

**Author:** ![binkly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@binkly](https://www.ruby-forum.com/u/binkly)\
**Post date:** [August 4, 2008, 1:39pm UTC](https://www.ruby-forum.com/t/odd-csv-behavior/144904/4 "2008-08-04T13:39:17Z")

</div>

Hello,

Binh Ly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But if I open the CSV file in TextMate, select all of the contents,  
> paste and save that content into a new CSV file, created with TextMate,  
> the CSV parser can process it just fine.

seems like a charset issue. maybe you should compare the two files  
(original and after copying with textmate) regarding character encoding  
and line endings. maybe even using a diff tool. this should help you  
figure out the exact problem, if you really need to know it.

Greetings,  
Niklas
