Aug-07-2018, 09:49 AM
amend my previous example
input_file = 'input_file.txt' # '/path/to/inputfile.txt' def do_comparison(block): # do comparison here print(block) with open(input_file) as in_file: header = next(in_file) block = [] for line in in_file: if block and line.strip() == '/##/': do_comparison(block=block) block = [] block.append(line) # eventually use line.strip() to remove trailing new line \n do_comparison(block) # that is for the last block
Output:['/##/\n', '/donnee1/XXXXXXXX\n', '/donnee2/A\n']
['/##/\n', '/donnee1/YYYYY\n', '/donnee2/B\n']
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs