Wipy , save float data on file and read it

Hi,

I’m new in programming with python. 

I have a problem with Wipy. I use Wipy to read data from an IMU (BNO055):

-I put float data in a list,

  • I convert this list in a string with the command ‘repr’,

  • I save the list in a file.txt that I opened before and with the command ‘write’ I put the list on it

Now the program create the file but it is empty.

Then I open the same file in mode ‘r’, I use the command ‘read’ to read file and I print the content of my file.

It print the list of float that I put inside the file before, but if I try to open my file it is empty.

Can you help me? 

HERE THE CODE THAT I WROTE

import machine
import pycom
from machine import Timer
import time
import lib_imu
from machine import I2C
from machine import PWM

Use command from my library to extract data from BNO055

lib_imu.set_configmode()
time.sleep(0.03)
lib_imu.set_units()
time.sleep(0.03)
lib_imu.set_mode(‘ndof’)
List =[]
for i in range(0,10):

extract data

eul = lib_imu.get_euler()
List.append(eul[0])
time.sleep(0.05)
if i > 5:

open file in mode to write on it

file_dati = open(“dati_posizione.txt”, “w”)
file_dati.write(str(List[0:len(List)]))
file_dati.close()
print(“fine”)
f = open(“dati_posizione.txt”, “r”)
print(“result”, f.read())
break

HERE WHAT IT PRINT
result [0.0, 176.9375, 176.9375, 176.9375, 176.9375, 176.9375, 176.9375]

I have to correct my description, I can’t find where file is. It isn’t in the same folder of the code and I don’t find it on my pc. 

Please help me :slight_smile:

Hi @vflorio94,

Thanks for being part of the GitHub Community Forum! We’re glad you’re here.

I wanted to jump in here, and mention that if you don’t get the help you’re looking for from this particular community, you might want to try getting help somewhere that focuses on WiPy. It’s definitely possible another GitHub user might have run into this same issue and can help, but the GitHub Community Forum focuses primarily on topics related to GitHub itself or collaboration on project development and ideas. We want to make sure you’re getting the best support you can, but this forum may not be the right place for this particular topic.

Best of luck!