Question: I am trying to make a program that takes 3 inputs from the user: `row/columns count` and `number range start` and `number range end`.

In my case and for example lets say `4 1 16` so it means `4 rows and columns` print `numbers from` `1-16`.

I have a problem accomplishing this.

```
#include <stdio.h>
#include <stdlib.h>

int num1,num2,count,i,y;
int main()
{
    count = 4;
    num1 = 1;
    num2 = 16;

for(i=1; i<=count; i++){

  for(y=num1; y<=num2; y++){
       printf("%d ",y);
    }

    printf("\n");
}

    return 0;
}

```

The output is

```
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

```

Whereas I want my output to be:

```
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

```

Answer: 
If you look at the [Documentation for ActiveRecord Import](https://github.com/zdennis/activerecord-import/wiki/Examples#import-using-columns-and-arrays), the method you are using takes an array of columns as the first argument (which you have) and the second argument is an array of arrays, where each array has the values you want to insert.

Your `values` variable is an array of hashes, so you'll need to convert it like so

```
values = values.map(&:values)
puts values
#=> [["xxx", "2017-11-28 20:42:57", 41.9322, 27.3253, 0, 198404, true, "address"], ["xxx", "2017-11-28 20:43:46", 47.0148, 39.1805, 16, 209726, true, "address"]]

```

For each hash in `values` we call [Hash#values](https://ruby-doc.org/core-2.4.2/Hash.html#method-i-values) - which returns a new array of just the values in the hash.

Or, just use [this version of #import](https://github.com/zdennis/activerecord-import/wiki/Examples#import-using-hashes) which takes a hash.

```
values = [{"plate":"xxx","timestamp":"2017-11-28 
 20:42:57","latitude":41.9322,"longitude":27.3253,"speed":0,"mileage":1984
 04,"ignition_on":true,"address":"address"},{"plate":"xxx","timestamp":"2017-11-28 20:43:46","latitude":47.0148,"longitude":39.1805,"speed":16,"mileage":209726,"ignition_on":true,"address":"address"}]

VehicleLocation.import values

```
You should be able to modify your code as follows:

```
locations = values.map do |attrs|
  VehicleLocation.new(attrs)
end

VehicleLocation.import(locations)

```

As shown in [the docs](https://github.com/zdennis/activerecord-import/wiki/Examples#import-using-activerecord-models)