I have the following field namesdemelog voyapro naisjdf naismc decoide decoccm travide travccm equiccm mariccmBelow is a sample of my file. There are more columns before the first fck=83... fck=83;fcv=naismc;fcv=naisjdf;fck=83;fmd=1422811694,;fmd=1422811694; fck=83;fcv=demelog;fck=83;fmd=1423134370; fck=83;fcv=demelog;fck=83;fmd=1422292546; fck=83;fcv=demelog;fck=83;fmd=1421774352; fck=83;fcv=decoccm;fck=83;fmd=1422853444; fck=83;fcv=voyapro;fck=83;fmd=1422270462; fck=83;fcv=voyapro;fcv=demelog;fck=83;fmd=1422183999,;fmd=1422206234,;Starting from fck=83 as you can see, I can have for line 2 fcv=demelog and the relevant fmd 1423134370 or for line 7, fcv=voyapro and fcv=demelog and the relevant fmd's as well fmd=1422183999, and fmd=1422206234;You do remember the first line demelog voyapro naisjdf naismc decoide decoccm travide travccm equiccm mariccm ?My aim is to have the following format (I will use line 2 and line 7 as the example)line 2 fck=83;fcv=demelog;;;;;;;;;fck=83;fmd=1423134370;;;;;;;;;line 7 fck=83;;fcv=voyapro;;;;;;;;;fck=83;;fmd=1422270462;;;;;;;;;As you can see, I have added extra columns both for fck=83 for the fcv and the fmd, related to this demelog voyapro naisjdf naismc decoide decoccm travide travccm equiccm mariccmI thought doing it with awk or sed or python , even if I have not a clue on how to do it with python nor awk and sed.Maybe I can add the demelog voyapro naisjdf naismc decoide decoccm travide travccm equiccm mariccm in a separate file and then do a search with an index . If the string is here , I'm doing nothing. If it is not here, I'm adding an extra column.Any helps are welcomed as I'm confused on where I should go technically speaking and starting to pull my hair.update This my attempt below in pythonimport reword_list=    ['fcv=demelog','fcv=voyapro','fcv=naisjdf','fcv=naismc','fcv=decoide','fcv=decoccm','fcv=travide','fcv=travccm','fcv=equiccm','fcv=mariccm']regex_string = (?<=\W)(%s)(?=\W) % ;.join(word_list)find=re.compile(regex_string)with open (idcacf_v5.txt, r) as myfile:    data=myfile.read().replace('\n', '')finder = re.compile(regex_string)string_to_be_searched = dataresults = finder.findall (%s  % string_to_be_searched)result_set = set(results)for word in word_list:    print (%s in string % word)As you can see, I need 2 things, to be able to index. Second thing is I need to be able to replicate what I have done with the fcv in term of order and put the same order with  fmd=timestamp of that line. 
how can I add an extra character after a word search
bash;sed;awk;python;perl
Here's something I cobbled up using the CSV module:#! /usr/bin/env python3import csv, sysword_list = ['fcv=demelog','fcv=voyapro','fcv=naisjdf','fcv=naismc','fcv=decoide','fcv=decoccm','fcv=travide','fcv=travccm','fcv=equiccm','fcv=mariccm']csvin = csv.reader (sys.stdin, delimiter=';')csvout = csv.writer (sys.stdout, delimiter=';')for row in csvin:    word_list_fck = [row[0]] + word_list    fmd_start = row[1:].index(row[0]) + 1    row_fcv = row[:fmd_start]  # split fcv from fmd    row_fmd = row[fmd_start:]    out_row = [entry if entry in row_fcv else ''  for entry in word_list_fck]    out_row = out_row + [row_fmd.pop(0) if out_row[i] != '' else '' for i in range(len(word_list_fck))]    csvout.writerow (out_row)Example output:$ python3 test.py < test.txtfck=83;;;fcv=naisjdf;fcv=naismc;;;;;;;fck=83;;;fmd=1422811694,;fmd=1422811694;;;;;;fck=83;fcv=demelog;;;;;;;;;;fck=83;fmd=1423134370;;;;;;;;;fck=83;fcv=demelog;;;;;;;;;;fck=83;fmd=1422292546;;;;;;;;;fck=83;fcv=demelog;;;;;;;;;;fck=83;fmd=1421774352;;;;;;;;;fck=83;;;;;;fcv=decoccm;;;;;fck=83;;;;;;fmd=1422853444;;;;fck=83;;fcv=voyapro;;;;;;;;;fck=83;;fmd=1422270462;;;;;;;;fck=83;fcv=demelog;fcv=voyapro;;;;;;;;;fck=83;fmd=1422183999,;fmd=1422206234,;;;;;;;;Notes:I rely on the first element in the row (fck=83 in the example cases) to be the entry separating the fcvs from the fmds. If not, this thing is going to be a whole lot more complicated.Given the repeated if bar in foo in the list comprehensions, this might be very slow depending on the length of each row.Regarding out_row = [entry if entry in row_fcv else ''  for entry in word_list_fck]: Consider how the desired output looks like when parsed by csv.reader to a list (taking, for example, the second line): [fck=83 ,fcv=demelog, , , , , , , , , , , fck=83, fmd=1423134370, , , , , , , , , ] - all the empty entries become empty strings.The output is supposed to contain empty entries for each fcv which did not appear in the input.Therefore, when building such a list for writing out using csv.writer, I use empty strings for all the fcv entries which do not appear in row_fcv (if entry in row_fcv else '').