0

I have a csv file, which has one row with many data. The problem is that this data is float, something like this (7.66907027311089). I use this code to import this data:

with open('Sygnal2.txt','r') as csvfile:
    plots = csv.reader(csvfile, delimiter=',')
    for row in plots:
        y.append(int(float(row[0])))

Even when I use float, when I print y I got a list of no float numbers. Any ideas how to change it?

2
  • 1
    why int? Use y.append(float(row[0])) Commented Mar 22, 2018 at 19:59
  • Ok, post it as an answer. Thanks man :) Commented Mar 22, 2018 at 20:00

1 Answer 1

1

You are converting twice - first you make a float from your string, and then an int from your float - simply do:

y.append(float(row[0]))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.