# FasterCSV: Two quick, simple, painless questions

**URL:** <https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446>\
**Category:** Rails\
**Created:** [July 18, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446 "2008-07-18T17:29:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 18, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446/1 "2008-07-18T17:29:07Z")

</div>

Hi, how is everybody doing?

1. How do I make sure that the file that is being uploaded is a CSV  
file, and not another kind of file?

2. Sometimes, when I’m parsing through the CSV file, it tries to read  
the row after the last row, and just reads in a bunch of nils. When I  
look at the row in Excel, it is completely blank, yet FasterCSV still  
tries to read it in. How can I stop this?

Any suggestions are appreciated.

Joe

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 18, 2008, 7:54pm UTC](https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446/2 "2008-07-18T19:54:47Z")

</div>

On Jul 18, 10:29 am, Joe P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi, how is everybody doing?

Doing great! Thanks for asking. 🙂

> 1. How do I make sure that the file that is being uploaded is a CSV  
> file, and not another kind of file?

Since CSV files are plain text files, I’m not sure what kind of  
verification you can do, short of trying to read it to see if it is a  
CSV file that you expect.

> 1. Sometimes, when I’m parsing through the CSV file, it tries to read  
> the row after the last row, and just reads in a bunch of nils. When I  
> look at the row in Excel, it is completely blank, yet FasterCSV still  
> tries to read it in. How can I stop this?
> 
> Any suggestions are appreciated.

Have you tried to look at the file in another viewer like Notepad to  
see the raw text? I suspect you have a trailing row of just commas at  
the end.

Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

[purpleworkshops.com](http://purpleworkshops.com)

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 19, 2008, 5:46pm UTC](https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446/3 "2008-07-19T17:46:07Z")

</div>

Jeff,  
I’ve also used FasterCSV and just pray that some of the longer fields  
don’t have escape characters to blow the importation of records.  
I appealed with this question to several forums and haven’t been able  
to find a solution.  
Ultimately, it’d be nice to have something similar to the ex: \<%=h  
@atx.description %\> h verb the way it escapes html characters when  
passing the string inside the two delimiters of one field in a .csv  
record.  
I hope this makes sense??  
Kathleen

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 24, 2008, 7:10am UTC](https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446/4 "2008-07-24T07:10:17Z")

</div>

On Jul 19, 10:45 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Kathleen  
> Can you give me an example of a CSV field with escape characters in  
> it? I’m having a hard time imagining what might be causing the  
> problem.

Thanks,  
Jeff

---

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [July 24, 2008, 3:27pm UTC](https://www.ruby-forum.com/t/fastercsv-two-quick-simple-painless-questions/143446/5 "2008-07-24T15:27:21Z")

</div>

Jeff,  
I was importing .csv records that had descriptions of inventory items.  
Some of these items were medical supplies that had the # sign (#15  
Surgical blade) and some had the " sign (2-0 18" Vicryl Suture).  
I would be most grateful if you have any ideas on this.  
Kathleen
