# Unitialized local variable using fastercsv with sqlite3

**URL:** <https://www.ruby-forum.com/t/unitialized-local-variable-using-fastercsv-with-sqlite3/128510>\
**Category:** Rails\
**Created:** [February 8, 2008, 10:11am UTC](https://www.ruby-forum.com/t/unitialized-local-variable-using-fastercsv-with-sqlite3/128510 "2008-02-08T10:11:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 10:11am UTC](https://www.ruby-forum.com/t/unitialized-local-variable-using-fastercsv-with-sqlite3/128510/1 "2008-02-08T10:11:04Z")

</div>

I want to import data into an sqlite3 db, but am fuzzy as to how to  
declare variables to get that done.

For:

:name =\> name

Both of the above need to be initialized or defined somehow, but I don’t  
know how.

thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ ruby import.rb  
[“one”]  
import.rb:11: undefined local variable or method `name' for main:Object (NameError) from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1458:in`each’  
from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/  
faster\_csv.rb:1003:in `foreach' from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1175:in`open’  
from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/  
faster\_csv.rb:1002:in `foreach’  
from import.rb:8  
thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ cat import.rb  
require ‘rubygems’  
require ‘fastercsv’  
require ‘/home/thufir/goodfellow-tool/config/environment.rb’

infile = “data.csv”

FCSV.foreach(infile) do |row|  
p row  
Call.new(  
:name =\> name  
)  
end  
thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ sqlite3 development.sqlite3  
SQLite version 3.4.1  
Enter “.help” for instructions  
sqlite\> .schema  
CREATE TABLE calls (“id” INTEGER PRIMARY KEY NOT NULL, “name” varchar  
(255) DEFAULT NULL);  
CREATE TABLE schema\_info (version integer);  
sqlite\>  
sqlite\> SELECT \* FROM calls;  
1|zero  
sqlite\> .quit  
thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ cat data.csv  
“one”  
“two”  
“three”  
thufir@arrakis ~/goodfellow-tool/db $

thanks,

Thufir
