General information on the usage of Mathematica can be found at the Wolfram Documentation Center.
Information on how to export data in different formats from Mathematica can be found here:
"How can I convert a .nb-file into a .m-file?"
To convert a .nb-file into a .m-file, you can open the .nb-file on Mathematica, select the lines which are supposed to appear in the .m-file and flag them as a Initialization Cell via Cell -> Cell Properties.
Now save the file (File -> Save As... ) and choose the format "Wolfram Mathematica Package (*.m)".
The Initialization Cell is then exported as a comment/text.