Pedram
Pedram

Reputation: 2611

How to update lines in a compressed file

I have a large compressed .gz file (gigabyte level) that contains one large .txt file. Currently, I can add new lines to the end of the file without any problem. But I wonder if there's any way to update or modify lines as we iterate through the file? In my case, I have tab-separated lines where each tab-separated item is a column in my dataset. I need to add one more column to this data. One way is to create a new file, read the .gz file lines one by one, update them, and write them to the new file. However, this is not ideal since 1) the file is huge, and writing will take time, and 2) I may need to do this multiple times and more frequently.

Upvotes: 1

Views: 47

Answers (0)

Related Questions