简体   繁体   中英

Skip a specified number of columns with numpy.genfromtxt() python 3.4 error

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM