Hello all,
I'm stuck again.  I'm in my 5th month of Ruby on Rails and getting
better but...

I'm uploading a .csv file using Paperclip and FasterCSV, then processing
the file after the upload is complete.

Small files work fine.  I tested a larger file and found that one cell
had 13,000 chars. needless to say the ORA-01704 was thrown.

When processing the file, I do line by line.

- controller -
def proc_csv
    @import = Import.find(params[:id])
    puts @import.csv.path
    lines = parse_csv_file(@import.csv.path)
    lines.shift #comment this line out if your CSV file doesn't contain
a header row
    if lines.size > 0
      @import.processed = lines.size
      lines.each do |line|
        case @import.datatype
          when "irb"
            new_irb(line)
          end
      end
      @import.save
        flash[:notice] = "CSV data processing was successful."
        redirect_to :action => "show", :id => @import.id
    else
      flash[:error] = "CSV data processing failed."
      render :action => "show", :id => @import.id
    end
  end

 private

  def parse_csv_file(path_to_csv)
    lines = []
    #
    require 'fastercsv'
    FasterCSV.foreach(path_to_csv) do |row|
      lines << row
    end
    lines
  end

  def new_irb(line)
    params = Hash.new
    params[:irb] = Hash.new
    params[:irb]["irb_number"] = line[0]
    params[:irb]["pi_full_name"] = line[1]
    params[:irb]["cr_quest_split"] = line[2]
    params[:irb]["cr_and_ct_split"] = line[3]
    params[:irb]["old_master_list"] = line[4]
    params[:irb]["title"] = line[5]
    params[:irb]["status_of_irb"] = line[6]
    params[:irb]["expiration_date"] = line[7]
    params[:irb]["review_level"] = line[8]
    params[:irb]["category"] = line[9]

    irb = Irb.new(params[:irb])
    irb.save
  end


The "title" is where the huge cell is.

I've done some research and I know that Oracle's datatype 'Clob' will
hold the size but only at 4,000 chars. at a time.
I'm just wondering how to do it?

Thank you for any help with this.

JohnM
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to