Question: I am trying to insert a new column into a CSV file after existing data. For example, my CSV file currently contains:

```
   Heading 1     Heading 2
   1 
   1
   0
   2
   1
   0

```

I have a list of integers in format:

```
 [1,0,1,2,1,2,1,1]

```

**How can i insert this list into the CSV file under 'Header 2'?**

So far all i have been able to achieve is adding the new list of integers underneath the current data, for example: 

```
   Heading 1     Heading 2
   1 
   1
   0
   2
   1
   0
   1
   0
   1
   2
   1
   2
   1
   1

```

Using the code: 

```
 #Open CSV file
 with open('C:\Data.csv','wb') as g:
            #New writer
    gw = csv.writer(g)
            #Add headings
    gw.writerow(["Heading 1","Heading 2"])
            #Write First list of data to heading 1 (orgList)
    gw.writerows([orgList[item]] for item in column)
            #For each value in new integer list, add row to CSV
    for val in newList:
        gw.writerow([val])

```

Answer: 
I guess this question is already kind of old but I came across the same problem.

Its not any "best practice" solution but here is what I do.

In `twig` you can use this `{{ path('yourRouteName') }}` thing in a perfect way. So in my `twig` file I have a structure like that:

```
...    
<a href="{{ path('myRoute') }}"> //results in e.g http://localhost/app_dev.php/myRoute
    <div id="clickMe">Click</div>
</a>

```

Now if someone clicks the div, I do the following in my `.js file`:

```
$('#clickMe').on('click', function(event) {
    event.preventDefault(); //prevents the default a href behaviour
    var url = $(this).closest('a').attr('href');
    $.ajax({
       url: url,
       method: 'POST',
       success: function(data) {
           console.log('GENIUS!');
      }  
    });
});

```

I know that this is not a solution for every situation where you want to trigger an Ajax request but I just leave this here and perhaps somebody thinks it's useful :)
Since this jQuery ajax function is placed on twig side and the url points to your application you can insert routing path

```
$.ajax({
    url: '{{ path("your_ajax_routing") }}',
    data: "url="+urlinput,
    dataType: 'html',
    timeout: 5000,
    success: function(data, status){
         // DO Stuff here
    }
});

```