Question: This is my code. I want to read the data from "data.txt" and convert it to type `float`, but there is a problem converting the data. The error says " could not convert string to float: ".

```
def CrearMatriz():
    archi = open("data.txt", "r")
    num = archi.readlines() 
    for lines in num:
        nums= [float(x) for x in lines.strip().split(",")]
    return nums
Numero = CrearMatriz()

```

The file contains numbers separated by commas.

Answer: 
The only way I can reproduce this is by having a blank line at the end of the file. So my data file looks like this:

```
12.34 , 56.78 , 90.12 , 34.56

```

There's a blank line after it, but I can't display that! So here it is in another format:

```
od -xc data.txt
0000000      3231    332e    2034    202c    3635    372e    2038    202c
           1   2   .   3   4       ,       5   6   .   7   8       ,    
0000020      3039    312e    2032    202c    3433    352e    0a36    000a
           9   0   .   1   2       ,       3   4   .   5   6  \n  \n    
0000037

```

Note the `\n\n` near end-of file.

Try this code:

```
def CrearMatriz():
    archi = open("data.txt", "r")
    num = archi.readlines() 
    for line in num:
        line=line.strip()
        if line:
            nums=[float(x) for x in line.split(",")]
    return nums
Numero = CrearMatriz()

```

However, that does not work if you have more than one line of numbers! It will only return the last line of numbers. So this might be better (depending on what you need):

```
def CrearMatriz():
    nums = []

    for line in open("data.txt", "r"):
        line=line.strip()
        if line:
            nums.extend([float(x) for x in line.split(",")])
    return nums
Numero = CrearMatriz()

```

If you want a list of lists, then change the `extend` to `append`.
I'm interested in the type of 

```
lines.strip().split(",")

```

It seems to me that strip() should work on a string, but lines would be a list of strings. You might need a double comprehension, something like:

```
[[float(x) for x in line.strip().split(",")] for line in lines]

```

Without your data, I can't verify this, though.

You might try removing the float(x) and just using

```
nums= [x for x in lines.strip().split(",")]
print(nums)

```

to see what the exact values are that float(x) is choking on.