Python Forum
Need help | splitting list into list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help | splitting list into list
#1
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
Reply
#2
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'
Reply
#3
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.
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,155 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Delete strings from a list to create a new only number list Dvdscot 8 1,511 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 914 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,829 Oct-26-2022, 04:03 PM
Last Post: deanhystad
Question Keyword to build list from list of objects? pfdjhfuys 3 1,555 Aug-06-2022, 11:39 PM
Last Post: Pedroski55
  Split a number to list and list sum must be number sunny9495 5 2,276 Apr-28-2022, 09:32 AM
Last Post: Dexty
  Splitting strings in list of strings jesse68 3 1,753 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  How to check if a list is in another list finndude 4 1,832 Jan-17-2022, 05:04 PM
Last Post: bowlofred
  Different out when using conda list and pip list Led_Zeppelin 1 4,020 Jan-14-2022, 09:30 PM
Last Post: snippsat
  Use one list as search key for another list with sublist of list jc4d 4 2,147 Jan-11-2022, 12:10 PM
Last Post: jc4d

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020