A block explorer will use a database to keep track of transactions and will update it as new blocks come in. It will probably not use RPC commands as it receives requests from its users.
This seems a great idea. Why haven't I thought it before... Once a new block is mined, the database will insert a new row of information. Still, though, I don't get how I'll convert the blk.dat files to csv. (So I can import it to a database)
You would run a series of RPC commands to get the transactions contained in each block. I have pseudo code describing how to import transactions into a database below:
#run for loop through each block
#run for loop to get the txid of each transaction in the blook you are looking at
#get the inputs, outputs, and amounts of inputs/outputs for each transaction
#update database accordingly
Once you have updated your database with existing blocks, you can create a script to run lines 2-4 each time your node receives a new block. You will also need to account for orphaned blocks once your database matches the current blockchain.