Question: My script is picking up a string when it should not, I get 

> 
> ValueError: could not convert string to float: for line `list_col.append(float(row[c].strip('"')))` in the code below 
> 
> 
> 

```
 with open(fileTwoName) as f:

    reader = csv.reader(f, delimiter=",")
    fileTwoColumnNames = next(reader)
    output_column .extend(fileTwoColumnNames[2:-1])
    number_of_columns = len(fileTwoColumnNames)-2

    for c in range(2,number_of_columns+2):
        list_col = []
        f.seek(1)
        next(reader)
        for row in reader:
            list_col.append(float(row[c].strip('"'))) 

        list_col_name_wise = []
        for k in range(0, len(number_eng)):
            list_col_name_wise.append(sum(list_col[start_row[k] - 1:start_row[k] - 1 + 1- total_case [k]]))
        data.append(list_col_name_wise)

```

I tested it by adding 

```
if list_col == str:
    list_col.append(float(row[c].strip('"'))) ` 

```

everything outputs ok but I need my `data` list to output as a float. Is there a way for me to account for both a str and float?

Answer: 
It will be something like that:

```
<?php
echo "<table>";
$column = 0;
$closed = false;
// loop through the array of files and print them all in a list
for($index=0; $index < $indexCount; $index++) {
$extension = substr($dirArray[$index], -3);
if ($extension == ('jpg' | 'JPG')){ // list only jpgs and JPG
 if($column === 0) { 
     echo "<tr>";
     $closed = false;
 }
echo '<td><img src=" thumbnail/' . $dirArray[$index] . '" alt="Image" /><span>' . $dirArray[$index] . '</span></td>';
$column++;
if($column === 3) {
  echo "</tr>";
  $column = 0;
  $closed = true;
}
}   
}

if(!$closed) {
    echo "</tr>";
}
echo "</table>";

```
If you really want to do this with PHP and render it to HTML:

Create an array with all images:

```
$images = [];
foreach(dirArray as $file) {
    $extension = substr($file, -3);
    if ($extension == ('jpg' | 'JPG')){
        $images[] = $file;
    }
}

```

Then you can create chunks out of that array (<http://php.net/manual/en/function.array-chunk.php>

```
$columns = 3;
$rows = array_chunk($images,$columns);

```

Then render your table:

```
$output = '<table>';
$i = 0;
foreach ( $rows as $row) {
    $output .= '<tr>';
    foreach($row as $file)
    {
        $output .= '<td><img src="thumbnail/' . $file . '" alt="Image" /><span>' . $file . '</span></td>';
    }

    //Add extra empty cells
    if ($i === count($rows) - 1) {
            $output .= str_repeat('<td>&nbsp;</td>', $columns - count($row));
    }
    $output .= '</tr>';

    $i++;
}
$output .= '</table>';

echo $output;

```

I would prefer not working with a table but use a responsive grid system ( <http://www.responsivegridsystem.com/>). 
You can still use the code above but replace the table parts with 's with the right classes.