Skip to content
Advertisement

Serialize ‘csv’ file as binary and append to file

How is it possible to achieve the following at the same time in python 3:

  • Serialize column names and numerical data as a binary file
  • Reopen the file and append additional numerical data

For example with the following data:

JavaScript

My approach with numpy

This approach allows to save data and append additional data. However the column names are missing and loading requires several calls to np.load.

JavaScript

My approach with pandas

This approach saves the data and header. However it seems not possible to append data to the file in a separate call.

JavaScript

Advertisement

Answer

JavaScript

You can append to the file without reading but the dfs wont be concatenated they are seperate entries. You can ofcourse read all the entries in a loop and concat later when it’s time to read the file.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement