Wilbert's website at SocSci

> Software> Python> Windaq

python/wdq.html 2014-08-07

WDQ

Opening wdq (windaq) files in Python can be done with this library. Save it in the same folder as your script or in a python standard folder. Following examples assume a data file called 'SAMPLE.WDQ' present in the same folder.

reading line by line:

#!/usr/bin/env python
import wdq

data = wdq.Wdq("SAMPLE.WDQ")
for l in data:
	print(l)

reading first ten samples:

#!/usr/bin/env python
import wdq

data = wdq.Wdq("SAMPLE.WDQ")
a = data.next(10)
print(a)

reading all (remaining) samples:

#!/usr/bin/env python
import wdq

data = wdq.Wdq("SAMPLE.WDQ")
a = data.next(-1)
print("shape: "+str(a.shape))

downsampling a factor of five:

#!/usr/bin/env python
import wdq

data = wdq.Wdq("SAMPLE.WDQ")
a = data.next(-1)[0::5,:]
print("shape: "+str(a.shape))

taking only the first column:

#!/usr/bin/env python
import wdq

data = wdq.Wdq("SAMPLE.WDQ")
a = data.next(-1)[:,0]
print("shape: "+str(a.shape))