I am new to Python and I am facing a weird issue with my code. Following is the part of my code where I am having the problem. The code is fetching a csv file and storing it to an array.
import requests
objNSEResponse = requests.get("https://www.nseindia.com" , headers = { "Referer":"https://www.nseindia.com" , "User-Agent":"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"})
objNSECookieJar = objNSEResponse.cookies
objNSEResponse = requests.get("https://www.nseindia.com/api/reportGSM?csv=true" , headers = {"Referer":"https://www.nseindia.com" , "User-Agent":"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"} , cookies = objNSECookieJar)
arrNSEGSMList = map(lambda arrNSEGSMRecord : arrNSEGSMRecord.replace("\"","").split(","), objNSEResponse.content.decode("utf-8-sig").replace("\n\"","\"").split("\n"))
print(list(arrNSEGSMList))
# delete unnecessary values
arrNSEGSMList = numpy.array(list(arrNSEGSMList1))
arrNSEGSMList = numpy.delete(arrNSEGSMList, [0], axis=0) # delete header row
arrNSEGSMList = numpy.delete(arrNSEGSMList, [2,3,4], axis=1) # delete all columns except stock symbol and serial number
Whenever I insert the statement : print(list(arrNSEGSMList)) , I get "IndexError: index 0 is out of bounds for axis 0 with size 0" at the following statement : arrNSEGSMList = numpy.delete(arrNSEGSMList, [0], axis=0). Zero length numpy array get created due to this print statement. If I remove the print statement then everything executes without any problem. I get the data which I require in the array "arrNSEGSMList". I am not able to figure out the reason for it.