r/learnruby • u/chucky_z 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
View all comments
Show parent comment
1
u/cmd-t Feb 10 '15 edited Feb 10 '15
Worse than ruby, you think?
Edit: sed only parses one line at the time, so I really don't know why you think it can't handle large files.Edit3: Just tried to sed a 4GB file and performance was not great. I'd expect it to be better. Larry Wall wrote perl because of stuff like this :(