[solved]-Using Python Slice D Like Remove Header Csv Datafile Using Slide Command Need Python S Ope Q38988010
Using Python Slice
I’d like to remove the header from a csv datafile using theslide command. I need to do this because Python’s ‘open’ commanddoes not accept other header stripped commands like ‘Header =False’ or ‘skiprows’. I don’t understand how to use slice to removea complete row and leave the rest of the filealone.
The dataset is from the diamonds training set. Here are thefirst two rows, followed by the rest of the function I’m workingon:
carat,cut,color,clarity,depth,table,price
0.23,Ideal,E,SI2,61.5,55,326
———
def loadDataSet():
dataMat = []; labelMat = []
fr = open(‘diamonds.csv’)
fr.skip_header = 2
for line in fr.readlines():
lineArr = line.strip().split()
dataMat.append([1.0, float(lineArr[0]), float(lineArr[1])])
labelMat.append(int(lineArr[2]))
return dataMat,labelMat
loadDataSet()
Expert Answer
Answer to Using Python Slice I’d like to remove the header from a csv datafile using the slide command. I need to do this because … . . .
OR

