Mysql
 SQL >> Database >  >> RDS >> Mysql

Correggere indentazione Python dopo uno split

Una regex può semplificare la divisione della riga:

import re

with open(infile) as in_f, open(outfile, 'w') as out_f:
  f = (i for i in in_f if i.rstrip())
  for line in f:
    _, k = line.split('\t', 1)
    x = re.findall(r'^1..100\t([+-])chr(\d+):(\d+)\.\.(\d+).+$', k)
    if not x:
      continue
    out_f.write(' '.join(x[0]) + '\n')