Is there a simple way to export all transactions related to a specific account/smartcontract to a CSV or some other plain text format?
Or you can simply use etherscan API and Json to CSV online service.
Use API, ie: https://api.etherscan.io/api?module=account&action=txlist&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&sort=asc and put it in the URL field of http://www.convertcsv.com/json-to-csv.htm
Recently, PeterChauYEG put together a node app / scraper for the DAO address that uses Etehrescan's API and outputs a CSV.
It will do the same for any address provided if you changed line 8 @ main.js:
const address = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'; to the address you would like to generate a CSV from.
If you find it useful, consider supporting the developer w/ a donation:
Here is a guide on how to export Ethereum data to csv https://medium.com/@medvedev1088/exporting-and-analyzing-ethereum-blockchain-f5353414a94e
It uses https://github.com/medvedev1088/ethereum-etl which outputs the data into
Column | Type | ------------------------|--------------------- block_number | bigint | block_hash | hex_string | block_parent_hash | hex_string | block_nonce | hex_string | block_sha3_uncles | hex_string | block_logs_bloom | hex_string | block_transactions_root | hex_string | block_state_root | hex_string | block_miner | hex_string | block_difficulty | bigint | block_total_difficulty | bigint | block_size | bigint | block_extra_data | hex_string | block_gas_limit | bigint | block_gas_used | bigint | block_timestamp | bigint | block_transaction_count | bigint |
Column | Type | --------------------|-------------- tx_hash | hex_string | tx_nonce | bigint | tx_block_hash | hex_string | tx_block_number | bigint | tx_index | bigint | tx_from | hex_string | tx_to | hex_string | tx_value | bigint | tx_gas | bigint | tx_gas_price | bigint | tx_input | hex_string |
Column | Type | --------------------|-------------- erc20_token | hex_string | erc20_from | hex_string | erc20_to | hex_string | erc20_value | bigint | erc20_tx_hash | hex_string | erc20_block_number | bigint |
There's no built-in way to do this. How difficult it is to do depends on what you mean by "related to a specific account".
Transactions initiated by an external account are easy to look up, as 'from' is one of the fields of the transaction - though there's no API call that returns only transactions initated by a given account you can at least scan transactions looking for ones you care about.
Transactions from an external account to another, or to a contract, are easy to detect, too, since there's also a 'to' field.
Where it gets complicated, however, is for value transfers initiated by a contract. These are often called "internal transactions", though in actual fact they're not transactions at all. There's no direct record of these in Ethereum, except by their side-effects (value transferred and state changes made), so there's no easy way to export them. Blockchain explorers that provide this functionality work by tracing transaction execution in the EVM, recording details about what took place.
However, let me plug my own project, Etherquery. It's a dump of Ethereum blockchain data - blocks, transactions, and transfers - to BigQuery, which permits arbitrary analytic queries, and supports exporting to a number of formats, including CSV. BigQuery is user-pays, but the first terabyte of processing each month is free. If you don't have a Google Cloud project, you'll need to create an empty one in order to access the public tables linked above.
If you are writing the contract you include events in your contract to track what's happening, and then you can log those events easily to a CSV file. This will include internal transactions as well, which addresses an issue noted above.