numpy loadtxt reading numbers

1340 views python

I'm trying to use numpy loadtxt to read some numbers(that represent X coordinate and Y coordinate)

I used Mac's TextEdit to write something like below

900 900
2400 900
480 2500
2900 2500

But when I tried to use numpy.loadtxt to read it

pts1 = np.loadtxt(upload('src_points.txt'))

I get an error saying

ValueError: could not convert string to float: '{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200'

What am I doing wrong? I am using numbers instead of string..

answered question

Are you sure it's the same file? What is this upload?

Yes, I'm sure it's the same file, I don't know why it's thinking my numbers are strings

1 Answer


It turns out that Mac's TextEdit saved the textfile in rtf format and that is causing this error. When I used SublimeText(a text editor), everything worked fine

posted this

Have an answer?


Please login first before posting an answer.