Last active
October 11, 2017 17:40
-
-
Save Kyonru/28cf92e48ee617f7eb186d0d9229d377 to your computer and use it in GitHub Desktop.
Find the line where the n-th character is
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Oct 11 12:21:18 2017 | |
Good way to find where the error is after a bad resolved merge conflict. | |
@author: kyonru | |
""" | |
with open ("name_of_the_file.extension", "r") as myfile: | |
data=myfile.readlines() | |
columnWanted=int(input("Write a column: ")) | |
cnt = 0; | |
for i in range(len(data)): | |
cnt += len(data[i]) | |
if(cnt >= columnWanted): | |
print("The line you want is aprox: " | |
+ str(i) + "\nLine:\n"+ data[i]) | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment