0
votes

This code worked to "gather" all of my text data before installing scipy:

#load a list with the filenames in root folder with .Spectrum extensions, stripping only the absorbance values
Spectral_Output = []
for file in glob.glob("*.Spectrum"):
    Spectral_Output.append(
        numpy.loadtxt(file, skiprows=1, usecols=(1)))

#convert to a numpy array and print dimensions
spectral_data = numpy.asarray(Spectral_Output)
print(spectral_data.shape)

#take only column 26 or the values for 2268; print stuff
Absorbance2268 = spectral_data[:, 25]

I then wanted to run a regression stats.linregress(x,y) on another concentration array, so I installed Scipy.

For some reason pip won't intsall scipy on Windows, so i installed numpy-1.11.3+mkl-cp27-cp27m-win32.whl and scipy-0.19.0-cp27-cp27m-win32.whl from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/ as recommended by scipy's site

Now, the code throws this error:

Traceback (most recent call last):
  File "C:\Spectrometer\Spectrometer\0330\Spectrum.py", line 31, in <module>
    numpy.loadtxt(file, skiprows=1, usecols=(1)))
  File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 790, in loadtxt
    usecols = list(usecols)
TypeError: 'int' object is not iterable

I am so out of my league. ANY help would be greatly appreciated.

1

1 Answers

3
votes

your tuple of columns only has one element, so you need a trailing comma, otherwise it won't be interpreted as an iterable:

numpy.loadtxt(file, skiprows=1, usecols=(1,)))

In numpy 1.11, an integer value for usecols is not permitted, unlike in the latest version. You likely down-versioned when you installed the whl.