This is driving me crazy. I have a script that pulls data from a csv. For each row it makes it a list. The reason is I want to merge two items based on a command line argument.
Here is my list as an example:
row = ['city', 'state', 'zip', 'zippostal', 'company']
Well I know if I do a join on row[0] and row[2] I will get
row = ['citystatezip', 'zippostal', 'company']
Well what if I wanted this….
row = ['companycityzip', 'state', 'zippostal']
How could I do this?
Edit:
Im sorry I didnt mean to be brief. What I have is a csv file with a bunch of data sometimes the city state and zip is in different fields but I need to merge them either by a , or – depends on what is needed. So what I did was make them into a list and based on command line arguements selecting what columns they are in I need them to merge so Ex.
column a column b column c column d ……
city state zip code
I need to merge column a into b by a “,”. Well that works fine but sometimes column f will be the city and column a will be the state. So how to I merge them in a list and have both values end up in column a but still return the rest of the row minus the updated vaule.
Maybe something like this?:
As a function:
Examples:
Edit: Here is a version that will return the remainder of the list after performing the joins: