How to deal with a very large text file?

前端 未结 7 1026
清歌不尽
清歌不尽 2021-02-07 15:19

I\'m currently writing something that needs to handle very large text files (a few GiB at least). What\'s needed here (and this is fixed) is:

  • CSV-based, following
7条回答
  •  滥情空心
    2021-02-07 15:48

    Would it be possible to split the file in "subfiles" (of course you must not split it within one Utf-8 char)? Then you need some meta data for each of the subfiles (total number of chars, and total number of lines).

    If you have this and the "subfiles" are relative small so that you can always load one compleatly then the handling becomes easy.

    Even the editing becomes easy to, because you only need to update the "subfile" and its meta data.

    If you would put it to the edge: then you could use a database and store one line per data base row. -- If this is a good idea strongly depends on your use case.

提交回复
热议问题