Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5820

Filter/remove empty lists Python

$
0
0

@Mertzi wrote:

Hey,
Im quite new to python and have some issues with what I presume really is a quite easy task..?
Im trying to import a file and filter out (get rid of) all the empty lists so that the remaining data will be more useful, but the "filter(None, list1) doesn't seem to do anything at all? What am I missing here?
Really greatful for any tips on how to do this.

Code:
str = open(filePath)
for i in str:
list1 = i.split()
list2 = filter(None, list1) #does this do anything at all!??
print list2

...and here is what it looks like:

Posts: 8

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 5820

Trending Articles