Gap Analysis/Report for CSV in Python 3.6.2 -


start         end mm0001        mm0009 mm0010        mm0020 mm0030        mm0039 mm0059        mm0071 

good afternoon, wanted create code in python in 3.6.2 allow me gaps in rows of consecutive numbers, such one. output screen missing numbers in format similar below:

mm0021    mm0029 mm0040    mm0051 mm0052    mm0058 

i've created code program based on answer found around here, don't believe it's complete, being done in python 2.7 believe. used basis trying do.

import csv open('thedata.csv') csvfile:     reader = csv.reader (csvfile)     line, row in enumerate(reader, 1):     if not row:        print 'start of line', line, 'contents', row 

any appreciated.

import csv  def out(*args):      print('{},{}'.format(*(str(i).rjust(4, "0") in args)))  prev = 0 data = csv.reader(open('thedata.csv'))  print(*next(data), sep=', ') #  header  line in data:     start, end = (int(s.strip()[2:]) s in line)      if start != prev+1:         out(prev+1, start-1)      prev = end     out(start, end) 

it’s ugly sorry, should work?

outputs comma separated text

if doesn’t work, or want save file, comment


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -