Skip to content

Instantly share code, notes, and snippets.

@tadcrazio
Created March 25, 2024 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadcrazio/ead54cc660bcf553fe506a265f1982ed to your computer and use it in GitHub Desktop.
Save tadcrazio/ead54cc660bcf553fe506a265f1982ed to your computer and use it in GitHub Desktop.
# Specify the path to your input and output CSV files
$inputCSV = "PathToKoinyTransactionFile.csv"
$outputCSV = "PathToExport.csv"
# Import the input CSV data
$data = Import-Csv $inputCSV -Delimiter ','
# Process each row of the input CSV
$results = $data | ForEach-Object {
# Calculate Net Value in USD (Assuming Gain is already in USD)
$netValueUSD = [decimal]$_.SentCostBasis + [decimal]$_.GainUSD + [decimal]$_.FeeValueUSD
# Create a new object (row) for the output CSV
[PSCustomObject]@{
Date = $_.Date
Type = $_.Type
'Sent Asset' = $_.'Sent Currency'
'Sent Amount' = $_.'Sent Amount'
'Received Asset' = $_.'Received Currency'
'Received Amount' = $_.'Received Amount'
'Fee Asset' = $_.'Fee Currency'
'Fee Amount' = $_.'Fee Amount'
'Market Value Currency' = 'USD' # Assuming market value in USD
'Market Value' = $_.'Net Value (USD)'
Description = $_.Description
'Transaction Hash' = $_.TxHash
'Transaction ID' = ''; # Leave blank if you don't have Transaction IDs
}
}
# Export the modified data to the output CSV
$results | Export-Csv -Path $outputCSV -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment