isonium / CloudAtCost-Wallet

Python code to export CloudAtCost Wallet Transactions to a .CSV file
MIT License
1 stars 1 forks source link

ValueError: could not convert string to float: '' #2

Closed bitremedy-sean closed 2 years ago

bitremedy-sean commented 2 years ago

Hello, Appears that I get the following message when trying to run this - it appears it's having an issue parsing the string "transaction_amount" to a float.

I'm very novice at python, and made some attempts but to no avail. Tried to .replace and .strip letters, in case this was related to the string appearing as "0.00001234 BTC", but I'm either too inexperienced or inept to figure this out. I have reverted my cac.py back to the original.

Here's the exact output in powershell: (attempting to run in Win10 21H1 19043.1415, Powershell as administrator):

Any help would be appreciated. Thank you for having written this script, would save so much time.

Output: Accessing https://wallet.cloudatcost.com/ Logging In... Generating 2FA Code... Loading Transactions... Saving Cookies... Processing Transactions... Traceback (most recent call last): File "C:\Users\User\Desktop\CloudAtCost-Wallet-main\cac.py", line 454, in main() File "C:\Users\User\Desktop\CloudAtCost-Wallet-main\cac.py", line 73, in main process_transactions(config, html) File "C:\Users\User\Desktop\CloudAtCost-Wallet-main\cac.py", line 380, in process_transactions totalBTCdeposited += float(transaction_amount) ValueError: could not convert string to float: ''

isonium commented 2 years ago

Please tell me your version of python and if you made any changes prior to the issue appearing. A lot of people use this tool and this is the first I have heard of this type of issue.

bitremedy-sean commented 2 years ago

Have some followup information: version: Python version 3.10.1 changes: tried with completely new download of the CloudAtCost-Wallet, no change

I scrubbed and completely removed Python, and reinstalled - to no change.

However, the interesting thing is that...

  1. I have 2 CAC accounts, an account with 6 miners (account A) with 7 miners (account B)
  2. Ran the cac.py script, and it was able to work with (account B), but not (account A).

Account A: purchased miners with BTC, has 2FA Account B: purchased with Credit Card, does not have 2FA

Very odd. Wondering if it's something to do with the initial "deposit/withdrawal" of the BTC used to purchase the miners on (Account A)

Output for script that worked: "Loading Transactions... Processing Transactions... Saving 'Transactions 2022-01-04 11-04.csv'

Total Transactions = 2146

Total BTC Deposited = 0.00725486 Total BTC Withdrawn = 0.01002242

Total BTC Mined = 0.0051429

Miner 22664 = 0.00198844 BTC Miner 22665 = 0.00099031 BTC Miner 25999 = 0.00035798 BTC Miner 28487 = 0.00160049 BTC Miner 45832 = 0.00010762 BTC Miner 45833 = 0.00005397 BTC Miner 49467 = 0.00004409 BTC "

isonium commented 2 years ago

Thanks for the update. Let me know what you determine. Both deposits and withdrawals should be handled without issue.

isonium commented 2 years ago

Any progress? I would like to close this issue soon. If you will paste the config files here with your credentials redacted, maybe I can help.

bitremedy-sean commented 2 years ago

Hi,

Sorry for delay with update -

I finally had success.

I tried this with multiple computers and configs to no success, but finally was able to find a workaround.

I threw in a few try: -command except Exception: pass

Around the code that was running into the Float/String errors

It worked! Thanks for making the original code. This will save me hours each month.

            fmv_cur = 0.0
            if str(transaction_epoch) in bitcoin:
                btc = bitcoin[str(transaction_epoch)]
                #fmv_USD = (float(btc_USD[3])+float(btc_USD[4]))/2.0
                fmv_cur = float(btc[2])

            try:
                transaction_amount_cur = float(transaction_amount) * fmv_cur
            except Exception:
                pass

            if transaction_type == "Withdraw":
                try:
                    totalBTCwithdrawn += float(transaction_amount)
                except Exception:
                    pass

            elif len(line1) == 3:  # Miner Deposit
                totalBTCmined += float(transaction_amount)
                totalBTCminedUSD += float(transaction_amount) * fmv_cur
                try:
                    minersBTCmined[miner_id] += float(transaction_amount)
                except:
                    minersBTCmined[miner_id] = float(transaction_amount)
            elif len(line1) == 2:  # BTC deposit
                try:
                    totalBTCdeposited += float(transaction_amount)
                except Exception:
                    pass
            transaction = []
            transaction.append(transaction_epoch)
            transaction.append(transaction_id)
            transaction.append(transaction_time)
            transaction.append(transaction_type)
            transaction.append(miner_id)
            transaction.append(transaction_amount)
            transaction.append(transaction_amount_type)