1

I have two column dataset where each element of first column corresponds to an array. So basically my second column elements are arrays and first column elements are just numbers. I need to write it in a file using Python and later read it in C. I know HDF5 is the best way to store arrays but I was wondering if there is any other effective way of writing it in .csv/.dat/.txt file. Since I have to read it in C I can't use things like numpy.savez.

Arpan Das
  • 321
  • 1
  • 3
  • 9

1 Answers1

0

I'd say write it to a text file. Per line put one first column number, followed by the second column's list of floats. Put a space between each element.

Assuming you know the maximum number of floats in the second column's array, and the maximum character length of each float, you can use fgets() to read the file line by line.

meaning-matters
  • 21,929
  • 10
  • 82
  • 142