0

I have 500+ strings in a file. If I simply copy-paste it into Rails console to assign the values to an array, it takes a lot of time(10 mins+) and the CPU usage spikes to maximum (the fans go crazy in my laptop) just to print whatever I have pasted. How can I skip that from being printed on screen because I'm sure assignment (without echo) shouldn't take more than a minute.

tekina
  • 571
  • 10
  • 21
  • Instead of copy&paste, read that file, e.g [File.foreach](http://www.ruby-doc.org/core-2.1.5/IO.html#method-c-foreach) – blelump Dec 04 '14 at 08:59

2 Answers2

3

Just add an empty string after that.

my_str = "paste here";""

Or mute the irb echo by setting

conf.echo = false
Siva
  • 7,780
  • 6
  • 47
  • 54
  • The first one won't really work since my assignment string is really big and printing that during assignment itself takes a lot of time. – tekina Dec 04 '14 at 11:39
1

Use 'File' class in ruby to read the file instead of just copy pasting.

File.open("path/to/your/file").each do |file|
  file.each_line do |line|
  dat_array = line.split()
end
end