tekina
tekina

Reputation: 572

Rails Console prevent assignment output to terminal

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.

Upvotes: 0

Views: 511

Answers (2)

Siva
Siva

Reputation: 8058

Just add an empty string after that.

my_str = "paste here";""

Or mute the irb echo by setting

conf.echo = false

Upvotes: 3

Arun Eapachen
Arun Eapachen

Reputation: 119

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

Upvotes: 1

Related Questions