Reputation: 315
I have 256 x 8 text file, i want to fetch it into np array(256,8), with int cast
import numpy as np
import cv2.cv2 as cv2
import math
import matplotlib.pyplot as plt
np.loadtxt(fname='data.txt')
then i get this error: could not convert string to float: '200.35,159.32,200.35,113.74,245.48,113.74,245.48,159.32'
Upvotes: 0
Views: 163
Reputation: 46
You need to split the strings into its separate values. loadtxt
has a parameter that does this:
np.loadtxt(fname='data.txt', delimiter=',')
This splits each row at the comma so that each number can be read as a separate value.
Upvotes: 3