I'm trying to read the data from excel sheet using the code
import xlrd
input= raw_input("put in the path name for file")
book=xlrd.open_workbook(input)
print book.nsheets
print book.sheet_names()
ws=book.sheet_by_index(0)
for rows in range(0,14):
data= ws.row_values(rows)
print data
and the answer I'm getting is this
[u'', u'', u'', u'', u'RS2 WW10 BKC', u'', u'RS2 WW23.2 BKC', u'']
[u'Slno', u'Title', u'Platform Target(W)', u'SoC Target (mW)', u'Platform Power(
W)', u'SoC Power (W)', u'Platform Power(W)', u'SoC Power (W)']
[u'', u'', u'', u'', u'', u'', u'', u'']
[1.0, u'Display Idle', 4766.0, 80.0, 5013.0, 145.0, 2714.0, 2422.0]
[2.0, u'VPB 1080p_30fps', 4999.0, 615.0, 4726.0, 1219.0, 2800.0, 2470.0]
[3.0, u'VPB _4k2k-H265', 5888.0, 1231.0, 5244.0, 1619.0, 0.0, 0.0]
[4.0, u'Connected standby', 181.0, 17.0, 266.0, 124.0, 176.0, 74.0]
[5.0, u'S3', 193.0, 52.0, 132.0, 94.0, 3719.0, 3245.0]
[6.0, u'Angry Bird', 6804.0, 2118.0, 7730.0, 3860.0, 2668.0, 2387.0]
[7.0, u'Browsing bench', 6209.0, 474.0, 5851.0, 1241.0, 3207.0, 2813.0]
[8.0, u'Dash Streaming', 5411.0, 663.0, 5576.0, 1842.0, 0.0, 0.0]
[9.0, u'MM14', 5651.0, 973.0, 7504.0, 3024.0, 0.0, 0.0]
[10.0, u'Miracast-VPB_Extend', 5072.0, 4007.0, 4196.0, 3081.0, 0.0, 0.0]
[11.0, u'Miracast-Idle', 5389.0, 756.0, 0.0, 0.0, 0.0, 0.0]
is there any way to skip the [u'', u'', u'', u'', values so that I can save the rest of data in another variable.
Answer: the issue was that I was directly fetching the value being unicode it got encoded with it. but if I print the index value then it comes without the u.
so, I directly used print data[0], data[1],data[2]
Hope this explains
You can use filtered_data = list(filter(None, data))
or you can loop over list to check if it is empty with
filtered_data = [a for a in data if a != ""]
then you can print filtered_data to see result.