更新时间:2023-12-03 21:18:52
您在这里有一个基本问题.当前的文件系统(据我所知)没有提供一种从文件中间删除一堆字节的功能.您可以覆盖现有字节,或写入新文件.因此,您的选择是:
You have a fundamental problem here. No current filesystem (that I am aware of) provides a facility to remove a bunch of bytes from the middle of a file. You can overwrite existing bytes, or write a new file. So, your options are:
\0
).但是,如果您想完全通用,则对于CSV文件,这不是选项,因为没有定义的注释字符.\0
). If you want to be completely generic though, this is not an option with CSV files, because there is no defined comment character.如果您要删除第一行,最后一个选项显然无济于事(但是,如果要删除末尾的行,这很方便).它还非常容易在过程中崩溃.
The last option obviously doesn't help much if you are trying to remove the first line (but it is handy if you want to remove a line near the end). It is also horribly vulnerable to crashing in the middle of the process.