0

I have array of floats written to a file. I need to read contents of this file and pass it as argument to another function. The problem is that on read from a file I receive a String. How do I convert from String to [Float]?

This is how I read from file:

import os
import matplotlib.pyplot as plt

filepath = "/pathToFile"
file = open(filePath, "r")

rawString = file.read()
#rawString is like '[569.675049, 706.275879, 776.753418, 785.674805]'

#somehow process rawString
processedArray = process(rawString)

plt.plot(processedArray)
plt.show()
Alexey Savchenko
  • 842
  • 2
  • 10
  • 31

0 Answers0