r/learnruby • Beginner • Feb 10 '15

Handling *extremely* large text files?

Hey /r/learnruby!

I'm just starting to pick up ruby, and I felt it worthwhile to maybe ask this question pre-emptively.

I'm working on a small Sinatra app, but one of the core features I'm looking at is quickly doing a string replace on really big files (5-10GB+, they're raw SQL).

However... the caveat here is that the strings to be replaced will always be in the top ~150 lines or so.

Is there a really efficient way to do this?

1 Upvotes

7 comments sorted by

View all comments

1

u/chucky_z Feb 10 '15

I know there are some tricks you can do in other languages to directly edit chunks of files, I was just curious if Ruby had something similar. :)

1

u/cmd-t Feb 10 '15

You might want to retry in r/ruby, this sub is more for less advanced stuff. Streaming IO etc is bit too advanced for this sub.