Skip to content

Commit

Permalink
CSV import fix. Issue salesking#1
Browse files Browse the repository at this point in the history
  • Loading branch information
vijendra committed Jan 26, 2012
1 parent 4b2449c commit 5ed5df1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/models/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ def parsed_data
@parsed_data ||= begin
CSV.read(full_filename, col_sep: col_sep, quote_char: quote_char, row_sep: "rn", encoding: "ISO-8859-1:UTF-8")
rescue CSV::MalformedCSVError
[]
rows = []
#one more attempt. #TODO check if this is required.
begin
f = File.open(full_filename, "r:ISO-8859-1")
CSV.parse(f.read.encode("UTF-8") , col_sep: col_sep, quote_char: quote_char) do |row|
rows << row
end
ensure
return rows
end
end
end

# store the uploaded tempfile.
def store_file
# TODO
Expand Down

0 comments on commit 5ed5df1

Please sign in to comment.