Need some help in converting gmsh file into the form which can be used in fenics code

You cannot read msh files directly into legacy dolfin.

See: What is wrong with my mesh? - #13 by dokken

You could also move to DOLFINx, which can read msh directly: