Python Forum

Full Version: Need help | splitting list into list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

My need is to read an excel, split data from a specific column , turn it into array of characters so that i print them into excel into 9 cells and color few characters.

Below is my approach so far. If incorrect, please rectify.

1 Read data from excel file [Done]
2 Put column data into a list as below [Done]

for row in range( 1, sheet.nrows ):
    data.append( sheet.cell_value( row, 2 ) ) # Append data from excel to list
2 Read this list and split each element into an array itself.Below doesn't work for me
for i in data:
    for j in range( len( i ) ):
        split_data.append(list( data[j]  ))
3 Once splitting , print them into excel
<No idea how to achieve this.I tried a lot from google about various python module but in vain. Lastly, i am seeking help here>

4 Future need : color the character 0 and O in excel sheet
<didn't reached there so far but any help on this would be thankful>

Thanks
V
An example of what the variable data contains is required and also an example of how split_data should look afterwards
split_data = []
data = 'unknown'

for i in data:
    for j in range(len(i)):
        split_data.append(list(data[j]))
print(split_data)
Output:
'not a clue what this should look like'
for i in data:
    for j in range( len( i ) ):
        split_data.append(list( data[j]  ))
I agree with Yoriz. I have no idea what is meant to do. For certain this wouldnt get you the results which list of list.specially i dont understand this part range(len(i)). Why do that?

Perhaps would really help you could provide us with the expected input and expected out.
May be i have confused you folks because of some erroneous code Undecided that doesnt work though i tried.
Below is my requirement which i tried in excel , but i will accept any other approach.

Input file type: .xlsx

Input data :

CODE NAME DETAILS Date
RAM TEMPORARY VALUE1 3/14/2019
TOP TEMPORARY VALUE2 3/14/2019


Output file type: xlsx/html
Output:
Output data: CODE NAME DETAILS Date RAM R A M 2 1 TEMPORARY VALUE1 3/14/2019 TOP T O P 3 0 TEMPORARY VALUE2 3/14/2019
Here, i need letter 0 is colored RED in NAME column and DETAILS columns in output file.
Similarly, letter O is colored blue.

Thanks
V