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 ended up using the jsrouting-bundle

Once installed I could simply do the following:

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

```

where urlgetter is a route defined in routing.yml like:

```
urlgetter:
    pattern: /ajax/urlgetter
    defaults: { _controller: MyAjaxBundle:SomeController:urlgetter }
    options:
        expose: true

```

notice the expose: true option has to be set for the route to work with jsrouting-bundle
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
    }
});

```