Browsed by
Tag: Python

A short script for testing writing many files to a folder

A short script for testing writing many files to a folder

The challenge: We want to see when the number of files in a folder decrease the performance on adding new files into the same folder. Two examples where we may need to do to this are: to get an overview of the performance of the file system node structure, or to test Windows function for 8dot3 format compatibility. The solution: We want to create a script that writes a large amount of files to the folder in question and is logging…

Read More Read More

Work programmatically with Google Spreadsheets Part 2

Work programmatically with Google Spreadsheets Part 2

A while back I wrote a short post on how you can write and read to Google Spreadsheets programmatically using Python and the package ‘gspread’. Last time the reading was done by first creating arrays with the addresses to where the values could be found in the spreadsheet, and then run through all the values and replace the addresses with the values. It worked fine, but it’s not best practice or very efficient as it makes many single requests on…

Read More Read More

Sanntid hjemme: Følg Ruter hjemmefra med Arduino og Python

Sanntid hjemme: Følg Ruter hjemmefra med Arduino og Python

Sanntidsskjermene som Ruter har satt opp ved flere t-bane, trikk og bussholdeplasser har blitt et kjærkomment bidrag til informasjonen du som reisende får om avganger. Ikke bare kan du ha stålkontroll over hvilke avganger som går, og i hvilken rekkefølge, du blir også oppdatert om estimert ankomsttid slik at du vet at du mista bussen du løp for å rekke eller om bussen har blitt forsinka i rush-trafikken. I tillegg til skjermene på holdeplassene som opplyser om sanntid, kan du få…

Read More Read More

Descriptive Statistical Methods in Code

Descriptive Statistical Methods in Code

Statistics can be mighty useful, and a little programming helps it getting even better. I often find that I through code can grasp the fundamental function behind how things work, and I have tried to apply this to statistics as well. In this case to descriptive statistics. Join me in this short attempt to let statistics unconceal itself. Getting ready: Extremistan and Mediocristan This little text is looking closer on some of the descriptive methods of statistics, and to do that…

Read More Read More

Work programmatically with Google Spreadsheets

Work programmatically with Google Spreadsheets

Some time back I authored a script which reads through a CSV formatted list, and based on the artists’ names tried to decide the nationality of the artists by querying the last.FM search engine and parsing the XML structured result. The script worked, and found and returned about 80% of the artists, and around 80% of these again had the conceptually similar artist. What if the alteration could be done in the document itself? For the CSV based script the…

Read More Read More

Data-wrangling: find country based on artist name

Data-wrangling: find country based on artist name

At the Clouds & Concerts project at the University of Oslo we are working with really interesting topics, based on interesting empirical data. Through our collaboration with the Norwegian streaming service provider WiMP we are together with Telenor and WiMP analysing a vast collection of data. More about the project’s data-part, also the ‘Clouds’ part of the project’s name can be found on the project’s web sites. Artist and Country One of the tasks at hand was to find out…

Read More Read More

Create Thumbnails Programatically

Create Thumbnails Programatically

If you have several images following a certain structure on a web page and want them as thumbnails, it can be useful to programatically create these. The manual way of creating thumbnails (using Photoshop or similar) can often be time consuming while the execution time for a script resizing an image is counted in microseconds. If you already have a script this can also be fitted for other similar situations. With the Python Image Library (PIL) thumbnails can be created…

Read More Read More

Åpne stortingsdata

Åpne stortingsdata

For en stund tilbake skrev jeg en liten post om hvordan stortingsdata kunne hentes ned fra Stortingets hjemmesider programmatisk. Som et utgangspunkt for å benytte data, enten til lek eller alvor, mener jeg offentlige data fungerer utmerket. Vi lever jo i et demokratisk samfunn, og uansett hvor mye mye tillit du måtte ha til politikerne eller mediene (eller hvor lite) har du som borger en rett til å gjøre dine egne analyser av offentlig informasjon og forhåpentligvis finner du noe…

Read More Read More

Screen Scraping med Python

Screen Scraping med Python

Tim Berners-Lee, Internetts pappa, snakker i et inspirerende TED foredrag om the web of data, og oppfordrer alle til å dele sine data. Ideen med web of data er at webben fram til i dag hovedsakelig har vært dokumentbasert og at denne nå endres til å bli mer databasert. I webbens dokumenter ligger det mye bakenforliggende informasjon hvor det semantiske innholdet ofte kan være utfordrende å hente ut, spesielt hvis du er en datamaskin. Selv om, ideeltt sett, all informasjon…

Read More Read More

Analysing the Bible

Analysing the Bible

The computer is a good tool in many areas but within its defining field, computations, it is great. With over a million computations per second even a big, large and heavy book (in its physical manifestation) can be sorted in just a blink of an eye. A while ago I tried to sort the King James version of the Bible. Inspiration During the last few years you may have encountered Jonathan Feinberg’s Wordle. This visualisation of word frequency in text…

Read More Read More