Question: I have two variations of CSV files. One of them uses double quotes, the other one doesn't.

```
A: "shipment_id","status","to_name","to_address_1" etc

B: shipment_id,status,to_name,to_address_1 etc

```

How can read the CSV and print out the value for `shipment_id` regardless of which type of CSV is submitted?

My code doesn't seem to work when the CSV doesn't use double quotes. 

```
with open(file_location) as f_obj:
    reader = csv.DictReader(f_obj, delimiter=',')
    for line in reader:
         print(line['shipment_id'])

```

Answer: 
* Use `setTimeout` instead of `setInterval`
* Loop over the array and depending on the index set a proper interval to wait for the execution of the callback (i.e `i * 10000` instead of `5 * 1000` for the delay, where `i` is the current index in the array)
* use [Array#map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) instead a normal for-loop as when the callbacks get executed the looping will be finished and the index variable won't hold a proper value

**Demo**

```js
let randomArray = [[1,10], [2,20], [3,30], [4,40]];

randomArray.map((el,i) => {
  setTimeout(() => {
    const AddressID = el[0];
    const Amount = parseFloat(el[1]);
    console.log(AddressID, Amount);
  }, i * 10000);
});
```

---

Another way would be to use a recursive function that creates a new timeout every time the callback of the previous was executed until you looped over the array

**Demo**

```js
let randomArray = [[1,10], [2,20], [3,30], [4,40]],
    i = 0;

(function loop() {
  setTimeout(() => {
    const AddressID = randomArray[i][0];
    const Amount = parseFloat(randomArray[i][1]);
    console.log(AddressID, Amount);
    i++;
    if(i < randomArray.length)
      loop();
  }, i * 10000);
})();
```
The key is to use a normal `for` loop instead of you're `of` `for` loop so that you can get the index of the array:

```
const randomArray = [];
  for (var i = 0; i < rows.length; ++i) {
    let row = rows[i];
    randomArray.push(row);
  }
 for (var j = 0; j < randomArray.length; j++) {
        var data = [randomArray[j]];
    setTimeOut(() => { console.log("Delay")}, j * 5000);
    const AddressID = data[0];
    const Amount = parseFloat(data[1]);
    console.log(AddressID, Amount);
    }

```

This should fire every five seconds, just change 5000 to whatever you like.