Question: This is a derivative from [this question](https://stackoverflow.com/questions/13017130/gnuplot-histogram-with-histeps-connects-bars/13021876#comment17689622_13021876). In that one, the following line comes up in a `python`script:

```
c1,c2 = [float(x) for x in line.split()] #convert line into 2 floats and unpack

```

when reading a data file with two columns.

Now, my **real** data file has 31 columns and I need to use columns 28 and 31 instead of 1 and 2. When I try the simplest (and ugliest) approach at escalating that line:

```
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31 = [float(x) for x in line.split()]

```

I get the error:

```
ValueError: too many values to unpack

```

How can I properly read all the columns in my file?

Answer: 
Another approach:

```
cols = [float(x) for x in line.split()]
c28, c31 = cols[27], cols[30]

```

So, the overall setup will look something like:

```
with open('<file name here>') as source_file:
    for line in source_file:
        cols = [float(x) for x in line.split()]
        c28, c31 = cols[27], cols[30]

```
```
cols = [float(x) for x in line.split()]
for i in len(cols):
    print i, cols[i]

```

there's no need to instantiate N variables, just use the array you have while reading the file

the for loops in this case helps you see how many values you really have