I have a file like this
apple
ae-pal
noun.
a fruit
ball
b'al
noun.
playing material
round shaped
and so on. so it starts with word then a blank line and pronunceation ( I konw above ones are stupid ones :P ). then part of speech and meaning. after each term there is blank line. what I want finally is to do a recursive call so that it pics first word and places in one table in database (mysql, may be) and then second into corrosponding row of same table and so on.
First I wanted to number this spaces. like 1 2 3 4 and so on. so that I can put all 1, 5, 9 that is 2*x+1 in one place and 2*x in another which way I will reach to my point and i can push them into a database getting finally my dictionary.
I could find a way of replacing empty lines with a number but couldn't get to how I could make them increasing number. I wonder how this can be implemented using sed, awk, or even python. no doubt regex is going to be there.
pseudo code
is line empty ?
yes ? give a number x (x =1)
increase x by 1
no ? go to next line
repeat till eof.
I hope I am clear enough!