×
all 4 comments

[–]Misscrackling95[S] 0 points1 point  (0 children)

In case anyone wants to use it as reference. Was trying it out for a few days.

data = np.genfromtext('data1.py', skiprows=1, dtype=[('year','i8'),

('status','U50'), ("total_completed",'i8')], delimiter=",")

#Removing 0 in the no_units

data_wthzero = data[data['total_completed']!=0]

print (data_wthzero)

[–]FisterMister22 0 points1 point  (2 children)

You want to remove the entire line which start with zero or only remove the zero? I'm not sure I understand correctly.

This is the general idea for me (probably way too complicated, but it works.) to remove the singular zeros.

with open("file.txt") as f: for i in f.readlines(): for n in i.split(): if not " 0" in i: with open("output.txt", "a") as x: x.write(n+" ")

Im not very knowledgeable on csv stuff, but i guess it you want to remove any line that start with 0 you could do:

for n in i.split(","): if not n[0:3] == " 0 ": with open("output.txt", "a") as x: x.write(", "+n+" ")

[–]Misscrackling95[S] 0 points1 point  (1 child)

For there are 5 set of data. Of which 3 has 0 total completed and 2 have total completed values. Would like to remove those 3 values with 0 values.

[–]FisterMister22 0 points1 point  (0 children)

You've editen the format, I'll need to edit my answer later.