I have a huge csv file which is over 250GB in size. I'd like to replace the characters " and ( with nothing. I feel like it should be pretty straight forward, but the file size makes sure that no editor opens the file.
I could also do it using python
, for which the following code could be used:
with open(file) as src:
lines = src.read()
print(lines.replace(old_string, new_string))
But this code requires the file to be in memory.
One option is to create another file, by writing lines replacing the unwanted characters. But that would mean having 2 files on disk with almost the same size. Unfortunately I don't have that much disk space on the server.
So is there a way to overwrite the lines and replace characters without creating a new file?
Some example csv lines are:
abc,"('91730', 'd9973')",1
def,"('91210', 'd9943')",1
ghi,"('91670', 'd9293')",1