0

I woud like to remove (delete) specific rows in csv file. But there are some conditions.

1.) File can't be buffered in memmory, becuse of it's size (1GB+)
2.) File MUST NOT be "touched" (rewriting file) 

My job is just to delete some rows in csv file, without changing any other rows - Very important, becuse of encoding and sending filtered csv file to company which prints that files.

Is there solution?

Thank you!

4
  • why don't use a database? Commented Aug 27, 2013 at 12:30
  • can you make a new file and then not touch the old file? Commented Aug 27, 2013 at 13:01
  • i can make a new file, but i must delete some rows from old file, and filtered file then send ahead. Problem is, becuse i MUSTN'T rewrite rows which will stay becuse of problems with encoding Commented Aug 27, 2013 at 13:06
  • so you have to send the old file, that is modified? or can you send the new file? Commented Aug 27, 2013 at 13:11

3 Answers 3

2

It can't be done. You want to delete content from a file, without modifying it. Those are mutually exclusive.

Sign up to request clarification or add additional context in comments.

2 Comments

tell that to OP's boss ;)
What's his number, I'd be happy to give him a call ;)
0

You can try using the mmap interface to replace the row bytes by space characters.

Comments

0

You can create an old timestamp using 'touch -t'. See the man page of 'touch' for more details.

touch -t 200510071138 old.dat

Just make sure you write down the original timestamp!

In order to remove the rows, you can use 'grep -v', which prints everything except your search terms.

grep -v baddata old.dat > new.dat

To modify with python, we're going to need some specific details of the file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.