By @mhawksey

Google Spreadsheets and floating point errors aka when is 65078736491511804 + 1 = 65078736491511808 (and automatically archiving your Twitter Status Updates)

Update: You can ignore most of this post as I noticed the Twitter API can return ids as a string. Here is the updated Export/Archive Twitter Status Updates Spreadsheet
I used to use my TwitterPad wordpress plugin to archive everything I said on Twitter. The main reason was often I find myself trying to remember links/resources I’ve previously tweeted. It worked well but every month I had to manually paginate my tweets to prevent the post getting too long.
Having got bored with this chore I wrote a Google Spreadsheet which interacts with the Twitter API to pull my timeline grabbing the last 3200 tweets. Part of this API allows you to just grab new updates since a tweet id (a similar parameter is available in the Twitter Search API used in Collect/backup tweets in a Google Spreadsheet on one sheet). Using this means I can setup a trigger in Google Apps Script to refresh my archive.
All was going well until I noticed it was pulling in duplicate entries. Part of the problem is Google Spreadsheet thinks 65078736491511804 is 65078736491511808. This meant the script was passing the wrong since id.
You can test this yourself by creating a new Google Spreadsheet and in the first cell [A1] enter 65078736491511804. With this cell highlighted if you select Format > Number and try to change it to nothing happens. This is because Google know there is a floating-point error and store the value as a text string.
If in the cell beneath the number (uh string 😉 [A2] you enter the formula =A1+1 you get 65,078,736,491,511,808 (if you get 6.51E+16 with the cell highlighted change Format > Number to Normal)
So if you want to start archiving your or someone else’s tweets you can make a copy of my Export/Archive Twitter Status Updates Google Spreadsheet. The health warning is there maybe missing or duplicates tweets. I have posted on the Google Apps Script forum to see if there is a way around this.

Exit mobile version