Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Transaction History converter

Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
03-17-2007 16:32
Hi guys :)

Not sure if this will be useful to anyone but me, but here goes :)

Backstory:

Recently, LL nerfed the in-world transaction history:
http://blog.secondlife.com/2007/03/15/transaction-history-moves-to-the-web-v1134-fixes-in-testing/

I personally find this very irritating, because I've got records going back over 3 years in the old in-world transaction history format, which pre-dates the web version. Personally, I find the web version hard to read.

So I figured I'd write a converter to convert the web-formatted transaction history into something that approximates the old in-world transaction history.

I also figured this'd be a fun exersize to learn a new language for me, Python. My impressions are that it's quite nice for what it is, with a few irritations. Mostly it's rather fussy and somewhat cryptic about what is implicitly mutable, and where references are, and that list[a:b] is a list of elements from list[a]..list[b-1] instead of list[a]..list as you might expect.

Get this (sample data) from:
https://secure-web1.secondlife.com/account/transactions.php
CODE

1 227092715 Object Sale 1 2006-10-13 11:39:31 Quilted Pillow Avatar 1 0
2 227076883 Object Sale 1 2006-10-13 11:26:43 Potted Plant Avatar 2 12
3 227059890 Object Sale 1 2006-10-13 11:13:18 Reclining Chair Kiosk Avatar 3 11
4 226938702 Object Sale 1 2006-10-13 09:32:56 Paired Nightstand Avatar 4 10
5 226604358 Object Sale 1 2006-10-13 04:03:02 Dining Table Avatar 5 9
6 226319571 Object Sale 1 2006-10-12 21:47:07 Dining Table Avatar 6 8
7 226059956 Object Sale 1 2006-10-12 17:49:48 Quilted Pillow Avatar 7 7
8 226054912 Object Sale 1 2006-10-12 17:45:44 Quilted Pillow Avatar 8 6
9 225869969 Currency Exchange 1 2006-10-12 15:23:48 Currency Exchange - order #1877413 Currency Linden 5
10 225869183 Gift 1 2006-10-12 15:23:10 Avatar 9 6
13 225852078 Object Sale 1 2006-10-12 15:09:43 Dining Table Avatar 10 5
14 225600080 Object Sale 1 2006-10-12 11:48:51 Dining Table Avatar 11 4
15 225245910 Object Sale 1 2006-10-12 06:14:52 Queen-size Bed Avatar 12 3
16 225109132 Currency Exchange 15 2006-10-12 03:17:15 Currency Exchange - order #1870596 Currency Linden 2
17 225101092 Object Sale 1 2006-10-12 03:05:39 Dining Table Avatar 13 17
18 22184943 Object Sale 1 2006-10-12 02:43:30 Dining Table Avatar 14 16
19 22122326 Gift 1 2006-10-12 01:16:40 Avatar 15 15
23 224964497 Object Sale 1 2006-10-11 23:57:33 Dining Table Avatar 15 14
24 224956774 Give Inventory 0 2006-10-11 23:45:41 Avatar 16 $(O
2(B5 224945807 Object Sale 1 2006-10-11 23:28:28 Throwpillow Avatar 17 13
26 224945702 Object Sale 1 2006-10-11 23:28:20 Avatar 18 12
27 224894895 Gift 1 2006-10-11 22:15:39 Avatar 19 11
28 224838829 Object Sale 1 2006-10-11 21:07:19 Reclining Chair Kiosk Avatar 20 10
29 224821801 Object Sale 1 2006-10-11 20:48:10 Dining Table Avatar 21 9
30 224778210 Currency Exchange 1 2006-10-11 20:03:1 Currency Exchange - order #1867727 Currency Linden 8
31 224715730 Object Sale 1 2006-10-11 19:05:33 Dining Table Avatar 22 9
32 224532923 Object Sale 1 2006-10-11 16:28:10 Dining Table Avatar 23 8
33 224484848 Object Sale 1 2006-10-11 15:48:52 Dining Table Avatar 24 7
34 224370492 Object Sale 1 2006-10-11 13:37:23 Dining Table Avatar 25 6
35 224330556 Currency Exchange 1 2006-10-11 13:04:36 Currency Exchange - order #1863556 Currency Linden 5
37 224217364 Object Sale 1 2006-10-11 11:31:40 Teal Sofa Avatar 26 6
38 224210739 Object Sale 1 2006-10-11 11:26:02 Teal Sofa Avatar 27 5
39 224094594 Object Sale 1 2006-10-11 09:41:13 Reclining Chair Avatar 28 4
40 223783451 Object Sale 1 2006-10-11 03:42:32 Dining Table Avatar 29 3
41 223738732 Object Sale 1 2006-10-11 02:36:31 Dining Table Avatar 30 2
42 223615537 Object Sale 1 2006-10-10 23:40:05 Dining Table Avatar 31 1


And paste it into the script to get (sample output):
CODE

Tuesday Oct 10, 2006
23:40:05 1 - Avatar 31 bought Dining Table

Wednesday Oct 11, 2006
02:36:31 1 - Avatar 30 bought Dining Table
03:42:32 1 - Avatar 29 bought Dining Table
09:41:13 1 - Avatar 28 bought Reclining Chair
11:26:02 1 - Avatar 27 bought Teal Sofa
11:31:40 1 - Avatar 26 bought Teal Sofa
13:37:23 1 - Avatar 25 bought Dining Table
15:48:52 1 - Avatar 24 bought Dining Table
16:28:10 1 - Avatar 23 bought Dining Table
19:05:33 1 - Avatar 22 bought Dining Table
20:48:10 1 - Avatar 21 bought Dining Table
21:07:19 1 - Avatar 20 bought Reclining Chair Kiosk
22:15:39 1 - Avatar 19 paid you
23:28:20 1 - Avatar 18 bought
23:28:28 1 - Avatar 17 bought Throwpillow
23:57:33 1 - Avatar 15 bought Dining Table

Thursday Oct 12, 2006
02:43:30 1 - Avatar 14 bought Dining Table
03:05:39 1 - Avatar 13 bought Dining Table
06:14:52 1 - Avatar 12 bought Queen-size Bed
11:48:51 1 - Avatar 11 bought Dining Table
15:09:43 1 - Avatar 10 bought Dining Table
15:23:10 1 - Avatar 9 paid you
17:45:44 1 - Avatar 8 bought Quilted Pillow
17:49:48 1 - Avatar 7 bought Quilted Pillow
21:47:07 1 - Avatar 6 bought Dining Table

Friday Oct 13, 2006
04:03:02 1 - Avatar 5 bought Dining Table
09:32:56 1 - Avatar 4 bought Paired Nightstand
11:13:18 1 - Avatar 3 bought Reclining Chair Kiosk
11:26:43 1 - Avatar 2 bought Potted Plant
11:39:31 1 - Avatar 1 bought Quilted Pillow


Python Script:
CODE

#!/usr/bin/python
# Francis wuz here

# https://secure-web1.secondlife.com/account/transactions.php
# Takes a copy/paste operation from here and converts it into the previously
# format that we used to be able to get in World->Account History

# No significant error handling in this script

# Headers
#############################################################################################
import sys
import exceptions

import time
import datetime

# Exceptions
#############################################################################################
customErrorMesg = "Custom Error Message"

# Constants
#############################################################################################

# Classes
#############################################################################################
class transactionClass:
"""Class for handling transactions"""
def __init__( self, param ):
self.type = param[0]
self.amount = int(param[1])
self.datetime = datetime.datetime(*time.strptime(param[2], "%Y-%m-%d %H:%M:%S")[0:6])
self.item = param[3]
self.avatar = param[4]

# Note to self: *unpacks a tuple into a list, and timetuple contains
# (year,month,day,hour,minute,second,weekday,yearday,daylightSavingAdjustment)

def getString( self ):
if self.type == 'Object Sale':
return "%s %6d - %s bought %s" % (self.datetime.strftime('%H:%M:%S'),
self.amount, self.avatar, self.item)
elif self.type == 'Gift':
return "%s %6d - %s paid you%s" % (self.datetime.strftime('%H:%M:%S'),
self.amount, self.avatar, self.item)
else:
return "%s %6d - %s :::%s::: %s" % (self.datetime.strftime('%H:%M:%S'),
self.amount, self.avatar, self.type,
self.item)

# Functions
#############################################################################################

# Main
#############################################################################################
try:
# read all the transactions
allTransactions = []
f = sys.stdin
for line in f.readlines():
s = line
entry = s.split( '\t' )[2:8]
for i in range(len(entry)):
entry = entry.strip()

if entry[0]=='Give Inventory' or entry[0]=='Currency Exchange' \
or entry[1]=='0' or entry[2]=='' or entry[2]=='0':
continue
entry = entry[0:1] + entry[2:]
transaction = transactionClass(entry)
allTransactions = [transaction] + allTransactions

# Print all the transactions
lastdate = datetime.date(1,1,1)
for t in allTransactions:
if lastdate != t.datetime.date():
lastdate = t.datetime.date()
print "\n", lastdate.strftime('%A %b %d, %Y')
print t.getString()

except exceptions.IOError, value:
print >> sys.stderr, "IO Error: "
print >> sys.stderr, " ", value

except customErrorMesg, value:
if value != None:
print >> sys.stderr, value

except:
print >> sys.stderr, 'Uncaught exception:', sys.exc_type, ", Value:", sys.exc_value



_____________________
--
~If you lived here, you would be home by now~
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
03-21-2007 04:21
/15/62/172025/1.html
_____________________
i've got nothing. ;)
Mathieu Basiat
Wavemaster
Join date: 24 Apr 2006
Posts: 57
03-24-2007 07:43
in order to automate getting the transaction data take a look at this thread