1
import os
import numpy as np
import matplotlib.pyplot as plt

# Open a file
path = "input/"

filelist = list(filter(lambda s: s.endswith(".asc"), os.listdir(path)))
firstImage = np.genfromtxt (" ".join(ln.split()[1:]) for ln in path+next(iter(filelist)))

what is wrong? getting: TypeError: Can't convert 'bytes' object to str implicitly

Klasik
  • 872
  • 1
  • 9
  • 29
  • What are you trying to do to the file name? Seems pretty unclear to me.. iterating over a string yield the letters. Can you write what `" ".join(ln.split()[1:]) for ln in path+next(iter(filelist))` yields to you? – unddoch Apr 18 '15 at 18:30
  • http://stackoverflow.com/questions/13311471/skip-a-specified-number-of-columns-with-numpy-genfromtxt my question is looks same but I cant go without errors. I need to remove first column to able shape in array : imageArray = np.zeros((len(filelist),) + firstImage.shape) – Klasik Apr 18 '15 at 18:42

1 Answers1

1

Check out the function's doc, it seems able to to all kinds of crazy things out of the box :

http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html

Including but not limited to, using the usecols parameters would allow you to skip using some columns.

Then there would be no need for fancy operations

Jiby
  • 1,865
  • 1
  • 13
  • 22