Search code examples
pythonhdf5pytableshdfql

Is there way to write hdf5 files row by row in Python?


For CSV files we could use

writer = csv.writer(output)
writer.writerow([a, b, c, d])

Is there anything like that for writing Hdf5 files?


Solution

  • This is similar to your other question.Error when trying to save hdf5 row where one column is a string and the other is an array of floats

    With pytables, you can create an empty table referencing a dtype that defines each datataype (in this example, 4 floats). Then you use table_object.append(row_data) to add 1 or more rows of data, where row_data can be defined with a list of tuples or a numpy recarray. See complete example I posted to answer question above.