Python Forum
2 or more data to be written in a row - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: 2 or more data to be written in a row (/thread-35639.html)



2 or more data to be written in a row - plumberpy - Nov-25-2021

A. I am using f.write(str(data1)) to save some data but I am limited to just 1 data per row. How can I save data1, data2, data3, ... in a row?

B. Any other way to save numeric data without having to use str?

Thanks.

P/S Just found a way to write in a row, using csv.
Managed to write 2 or more data in a row using csv. So closing this.

If there are other ways to do, please let me know. Thanks.


RE: 2 or more data to be written in a row - paul18fr - Nov-25-2021

If you're using arrays (1D/2D), you can use numpy.savetxt to have a cvs like file


RE: 2 or more data to be written in a row - Gribouillis - Nov-25-2021

Also I don't understand how using f.write() prevents you from writing more than one value in a row.