• towerful@programming.dev
    link
    fedilink
    arrow-up
    11
    ·
    15 hours ago

    Smaller file size, lower data rate, less computational overhead, no conversion loss.

    A 64 bit float requires 64 bits to store.
    ASCII representation of a 64 bit float (in the example above) is 21 characters or 168 bits.
    Also, if every record is the same then there is a huge overhead for storing the name of each value. Plus the extra spaces, commas and braces.
    So, you are at least doubling the file size and data throughput. And there is precision loss when converting float-string-float. Plus the computational overhead of doing those conversions.

    Something like sqlite is lightweight, fast and will store the native data types.
    It is widely supported, and allows for easy querying of the data.
    Also makes it easy for 3rd party programs to interact with the data.

    If you are ever thinking of implementing some sort of data storage in files, consider sqlite first.