Converting load cell data to .txt file

82 views Asked by At

I am trying to gather data from my load cell that is hooked up to a raspberry pi 3B. I have the script reading data but am trying to figure out how to export that data into a .txt file.

I have seen some info on how to create .txt files with text but not much for integers. I need something more fit to my application.

The script takes x (not sure on the exact value) samples of data per second so the amount of data can vary depending on how long I run the script. I want a text file to be created once I stop the script and record the data points on separate lines like in the attached image. I found a way to do it with words/letters but integers wouldn't work.

Let me know if there is anything I can share to help find a solution easier. I appreciate all the input.

1

There are 1 answers

1
iohans On

In Python, you can use "open" with the "w" mode to create a new file:

file = open("load_cell_data.txt", "w")

Pass the data in with file.write and then close the file with file.close.

Docs: https://docs.python.org/3/library/functions.html#open