Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Breaking change (fixes #25): rename DelimitedParser into CsvParser to…
Browse files Browse the repository at this point in the history
… avoid confusion. This parser uses FasterCSV under the hood, which means it can choke on faulty data. Renaming it makes it clearer to the end-user and I will emphasize this in the documentation.
  • Loading branch information
thbar committed Jun 19, 2011
1 parent 8699ac4 commit 7a64fb2
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ETL #:nodoc:
module Parser #:nodoc:
# Parses delimited files
class DelimitedParser < ETL::Parser::Parser
# Parses CSV files
class CsvParser < ETL::Parser::Parser
# Initialize the parser
# * <tt>source</tt>: The Source object
# * <tt>options</tt>: Hash of options for the parser, defaults to an empty hash
Expand Down
2 changes: 1 addition & 1 deletion test/delimited.ctl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source :in, {
:file => 'data/delimited.txt',
:parser => {
:name => :delimited
:name => :csv
}
},
[
Expand Down
4 changes: 1 addition & 3 deletions test/delimited_absolute.ctl
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# puts "executing delimited.ctl"

source :in, {
:file => '/tmp/delimited_abs.txt',
:parser => {
:name => :delimited
:name => :csv
}
},
[
Expand Down
4 changes: 1 addition & 3 deletions test/delimited_destination_db.ctl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# puts "executing delimited.ctl"

source :in, {
:file => 'data/delimited.txt',
:parser => :delimited
:parser => :csv
},
[
:id,
Expand Down
2 changes: 1 addition & 1 deletion test/delimited_excel.ctl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source :in, {
:file => 'data/delimited.txt',
:parser => {
:name => :delimited
:name => :csv
}
},
[
Expand Down
2 changes: 1 addition & 1 deletion test/delimited_insert_update.ctl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source :in, {
:file => 'data/delimited.txt',
:parser => {
:name => :delimited
:name => :csv
}
},
[
Expand Down
2 changes: 1 addition & 1 deletion test/delimited_update.ctl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source :in, {
:file => 'data/delimited.txt',
:parser => {
:name => :delimited
:name => :csv
}
},
[
Expand Down
2 changes: 1 addition & 1 deletion test/delimited_with_bulk_load.ctl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ outfile = 'output/people.txt'
source :in, {
:file => infile,
:parser => {
:name => :delimited
:name => :csv
}
},
[
Expand Down
2 changes: 1 addition & 1 deletion test/multiple_delimited.ctl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source :in, {
:file => 'data/multiple_delimited_*.txt',
:parser => :delimited
:parser => :csv
},
[
:first_name,
Expand Down
4 changes: 2 additions & 2 deletions test/multiple_source_delimited.ctl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source :source1, {
:file => 'data/multiple_delimited_*.txt',
:parser => :delimited
:parser => :csv
},
[
:first_name,
Expand All @@ -16,7 +16,7 @@ source :source1, {

source :source2, {
:file => 'data/multiple_delimited_*.txt',
:parser => :delimited
:parser => :csv
},
[
:first_name,
Expand Down
4 changes: 2 additions & 2 deletions test/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Test the flat text parsers
class ParserTest < Test::Unit::TestCase
# Test parsing delimited data
def test_delimited_parser
def test_csv_parser
control = ETL::Control::Control.resolve(File.dirname(__FILE__) + '/delimited.ctl')
parser = ETL::Parser::DelimitedParser.new(control.sources.first)
parser = ETL::Parser::CsvParser.new(control.sources.first)
rows = parser.collect { |row| row }
assert_equal 3, rows.length
assert_equal({:first_name=>"Chris", :last_name=>"Smith", :ssn=>"111223333", :age=>"24", :sex => 'M'}, rows.first)
Expand Down
2 changes: 1 addition & 1 deletion test/performance/delimited.ctl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source :in, {
:file => 'delimited.txt',
:parser => :delimited
:parser => :csv
},
[
:first_name,
Expand Down
2 changes: 1 addition & 1 deletion test/scd_test_type_1.ctl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source :in, {
:file => "scd/#{ENV['run_number']}.txt",
:parser => :delimited
:parser => :csv
},
[
:first_name,
Expand Down
2 changes: 1 addition & 1 deletion test/scd_test_type_2.ctl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source :in, {
:file => "scd/#{ENV['run_number']}.txt",
:parser => :delimited
:parser => :csv
},
[
:first_name,
Expand Down
6 changes: 3 additions & 3 deletions test/source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SourceTest < Test::Unit::TestCase
control = ETL::Control::Control.parse(File.dirname(__FILE__) + '/delimited.ctl')
configuration = {
:file => 'data/delimited.txt',
:parser => :delimited
:parser => :csv
}
definition = self.definition + [:sex]

Expand All @@ -42,7 +42,7 @@ class SourceTest < Test::Unit::TestCase
control = ETL::Control::Control.parse(File.dirname(__FILE__) + '/multiple_delimited.ctl')
configuration = {
:file => 'data/multiple_delimited_*.txt',
:parser => :delimited
:parser => :csv
}

source = ETL::Control::FileSource.new(control, configuration, definition)
Expand All @@ -61,7 +61,7 @@ class SourceTest < Test::Unit::TestCase
'/delimited_absolute.ctl')
configuration = {
:file => '/tmp/delimited_abs.txt',
:parser => :delimited
:parser => :csv
}
definition = self.definition + [:sex]

Expand Down

0 comments on commit 7a64fb2

Please sign in to comment.