Vote count: 0 I have used this code in helper to display the count based on the status - def to_do_count Task.where(status: 0).count end def in_progress_count Task.where(status: 1).count end def paused_count Task.where(status: 2).count end def completed_count Task.where(status: 3).count end I need help to optimize this code as there are lot of repetitions. asked 25 secs agoAasish Sharma Let's block ads! بخوانید...
ادامه مطلبVote count: 0 I use Python. I have 100 zip files. Each zipfile contains more than 100 xmlfiles. Using the xmlfiles I create csvfiles. from xml.etree.ElementTree import fromstring import zipfile from multiprocessing import Process def parse_xml_for_csv1(data, writer1): root = fromstring(data) for node in root.iter('name'): writer1.writerow(node.get('value')) def create_csv1(): with open('output1.csv', 'w') as f1: writer1 = csv.writer(f1) for i in range(1, 100): z = zipfile.ZipFile('xml' + str(i) + '.zip') # z.namelist() contains more than 100 xml files for finfo in z.namelist(): data = z.read(finfo) parse_xml_for_csv1(data, writer1) def create_csv2(): with open('output2.csv', 'w') as f2: writ...
ادامه مطلب