Answer the question
In order to leave comments, you need to log in
Multiline replacement?
Good day to all!
There is a very large amount of information like:
10,11,12,13,14,15,16,17,18,19,20,21,22 | 3400000300000010000
23,24,25,26,27,28,29,30,31,32,33,34,35 | 3400000300000010000
................................. ... . . .. .. .............. | ....................................
33,34,35,36,37,38,38a, 39,4,40,40a,4a | 3400000300000170000
How can I replace row data into a column, while maintaining a range of 2 columns.
10 | 3400000300000010000
11 | 3400000300000010000 etc.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
res = open('res.txt', 'w')
with open('file.txt') as lines:
for line in lines:
_ = line.splitlines()[0].split(' | ')
for number in _[0].split(','):
res.write('%s|%s\n' % (number, _[1]))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question