Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write list of list to CSV?
#7
(Feb-24-2019, 07:58 AM)searching1 Wrote: After running this from my original file which Im working, It's not writing any data on the CSV, maybe u have encountered/ any idea with this?
I am not sure I understand this

(Feb-24-2019, 07:58 AM)searching1 Wrote: opo = [[ele] for ele in opo] - What we did here is we create a specifically significant variable(ELE) which we put the opo list into the ele list.

we use list comprehension. ele is just a variable that we used to convert the list to list of lists. we don't actually care about it, so we can reuse it in the list coprehension used to turn descname to list of lists
opo = [[ele] for ele in opo]
is same as
new_opo = []
    for ele in opo:
        new_opo.appned([ele])
opo = new_opo[:]
(Feb-24-2019, 07:58 AM)searching1 Wrote: then we put the list into zip and this itertools.izip_longest(*iterables[, fillvalue]) is fill all the blank data a loop until find the longest match/value.

it's same as zip, however if some of the iterables are shorter than others, it will use fillvalue to work as if they were equal length
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Write list of list to CSV? - by searching1 - Feb-24-2019, 01:13 AM
RE: Write list of list to CSV? - by Larz60+ - Feb-24-2019, 01:28 AM
RE: Write list of list to CSV? - by Larz60+ - Feb-24-2019, 01:49 AM
RE: Write list of list to CSV? - by searching1 - Feb-24-2019, 01:50 AM
RE: Write list of list to CSV? - by buran - Feb-24-2019, 06:42 AM
RE: Write list of list to CSV? - by searching1 - Feb-24-2019, 07:58 AM
RE: Write list of list to CSV? - by buran - Feb-24-2019, 08:17 AM
RE: Write list of list to CSV? - by searching1 - Feb-24-2019, 08:28 AM
RE: Write list of list to CSV? - by buran - Feb-24-2019, 08:43 AM
RE: Write list of list to CSV? - by searching1 - Feb-24-2019, 09:03 AM
RE: Write list of list to CSV? - by buran - Feb-24-2019, 09:10 AM
RE: Write list of list to CSV? - by searching1 - Feb-24-2019, 09:33 AM
RE: Write list of list to CSV? - by buran - Feb-24-2019, 09:37 AM
RE: Write list of list to CSV? - by searching1 - Feb-24-2019, 06:41 PM
RE: Write list of list to CSV? - by buran - Feb-24-2019, 06:43 PM
RE: Write list of list to CSV? - by SmartGrid - Feb-24-2019, 07:57 PM
RE: Write list of list to CSV? - by searching1 - Feb-25-2019, 03:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Strange behavior list of list mmhmjanssen 3 378 May-09-2024, 11:32 AM
Last Post: mmhmjanssen
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,305 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Delete strings from a list to create a new only number list Dvdscot 8 1,650 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 965 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,929 Oct-26-2022, 04:03 PM
Last Post: deanhystad
Question Keyword to build list from list of objects? pfdjhfuys 3 1,635 Aug-06-2022, 11:39 PM
Last Post: Pedroski55
  Split a number to list and list sum must be number sunny9495 5 2,373 Apr-28-2022, 09:32 AM
Last Post: Dexty
  How to check if a list is in another list finndude 4 1,889 Jan-17-2022, 05:04 PM
Last Post: bowlofred
  Different out when using conda list and pip list Led_Zeppelin 1 4,128 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,235 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