# Get the data into an array, or grab it a line at a time; # Read a line/array element to a var, $input; # ie, up to the first return $may_be_a_full_entry_or_may_not = $input; Loop and read the next line to $input; use a regex to see if it starts with "day\t" if (it matches) { STORE $may_be_a_full_entry_or_may_not; s/"blank"//; # or use a capturing regex # whatever that is: tab, space, multi-spaces??? # be careful to make only the first "blank" go away! STORE $input; } else { s/"blank"//; # or use a capturing regex $input = $may_be_a_full_entry_or_may_not; . $input; # concat the two lines STORE $input to your db; }