[Numpy-discussion] loading data with gaps

Tim Michelsen timmichelsen@gmx-topmail...
Thu Apr 3 17:44:09 CDT 2008


Hello!

How can I load a data file (e.g. CSV, DAT) in ASCII which has some gaps?

The file has been saved with from a spreadsheet program which leaves 
cells with not data empty:


1,23.
2,13.
3,
4,34.

Would this code be correct:
### test_loadtxt.py ###
import numpy
import maskedarray

# load data which has empty 'cells' as beeing saved from spreadsheet:
# 1,23.
# 2,13.
# 3,
# 4,34.
data = numpy.loadtxt('./loadtxt_test.csv',dtype=str,delimiter=',')


# create a masked array with all no data ('', empty cells from CSV) masked
my_masked_array = maskedarray.masked_equal(data,'')
######

* How can I change the data type of my maskedarray (my_masked_array) to 
a type that allows me to perform calulations?

* Would you do this task differently or more efficient?

* What possibilities do I have to estimate/interpolate the masked values?
A example would be nice.

* How to I convert maskedarray (my_masked_array) to a array without 
masked values?

Thanks in advance for your help,
Tim Michelsenholg



More information about the Numpy-discussion mailing list