'Add word using sed to the last column of csv

I tried the following sed and even I have set $ to set the path at the end it doesn't seem to be working. Also I dont know if there's any way of execute this line by line with a while or for:

sed -E 's/$/Location/'

But the ouput i recive is:

Locationi,d,nm,yr,dt,mnn,rmd,g,gnr,rc,ct,st,sgns,tt,fl,cmr,lng,lt,gcdng
Location,2018,2018-10-25,sh,vhcl,28,M,B,St. Ls,MO,F,attack,flng,False,-90.219,38.773,True

Input

 wi,d,nm,yr,dt,mnn,rmd,g,gnr,rc,ct,st,sgns,tt,fl,cmr,lng,lt,gcdng
 2,4141,Armond,2018,2018-10-25,sh,vhcl,28,M,B,St. Ls,MO,F,attack,flng,False,-90.219,38.773,True

Ouput expected

wi,d,nm,yr,dt,mnn,rmd,g,gnr,rc,ct,st,sgns,tt,fl,cmr,lng,lt,gcdng
2,4141,Armond,2018,2018-10-25,sh,vhcl,28,M,B,St. Ls,MO,F,attack,flng,False,-90.219,38.773,True Location


Solution 1:[1]

If you have the example file ex.csv containing a header-row and 3 data-rows like this:

col1,col2,col3
1,2,3
4,5,6
7,8,9

So you du the replacement from row 2 and onward to avoid the header. This is the 2,$ part.

Then you do the search and replace at the end of each row. s/$/ Location/

Put it all together as:

$ sed '2,$s/$/ Location/' ex.csv 
col1,col2,col3
1,2,3 Location
4,5,6 Location
7,8,9 Location

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 UlfR