I really hope I don't mess this up, but this is my understanding of FB's. I have not used TIA Portal specifically, but as I understand it, it is just a suite containing the various Siemens' software (Simatic Step 7 Manager, STARTER, etc.)
After you have created an FB in Simatic Manager via Insert Object -> Function Block, you can open the newly created FB and begin coding in it. Once inside the new FB, there is a Declaration Table at the top of the page with In, Out, In/Out, Temp, Stat variable trees. This is where you label and define the generic variables to be used inside the FB for processing.
At my site, we have a generic double-solenoid valve FB called many different places. For example, you have a valve with two solenoids each powered from an output from a Siemens' module. You could define an "Out" for "Sol_A" of type "Boolean" in this new FB's Declaration Table. Now, if you save this block, and then make a block call in another FC/FB/OB for this FB, it will display the FB and FB number as a box, with a variable on the outgoing side of the box labeled "Sol_A". You would then assign the address (Absolute or Indirect) for the specific output you want turned on to energize this solenoid next to this "Out" parameter.
The process is repeated for all other generic variables inside your FB. Determine the nature of this signal: is it only brought into the FB (In); is it only an output of the FB (Out); is a signal both brought into the FB, processed, and sent out (In/Out); a Temp acted on only during each scan cycle and then "forgotten"; or a "Stat" which is a Static variable retained after the execution of the block and saved in the associated Instance DB of the FB. Then, define a name and the type of data related to this variable: Boolean, S5Time, INT, REAL, etc.
When this block is called in another FC/FB/OB, you will then assign all the actual addresses you want manipulated in the respective slots that are populated on the incoming and outgoing sides of the FB.
The water gets murkier for me when you get into Multi-Instance DB's, combining Instance DB's into a calling FB's Instance DB, but I would really recommend reading the Siemens' manuals for "Simatic Programming with STEP 7" and the programming manuals for whatever processor you are using.
As for the .CSV question, I cannot help you there in Step 7. If you are using WonderWare, I know there is a way to export tag data to a .CSV at different intervals for data logging, though I have never personally used it.