- #1
Bala06
- 10
- 0
Dear Programmers
I am having text file having huge data.
From the text file i would like to map the two numbers that are present in the same brackets and the values should not considered if they are present in different numbers.
say for example I want to map number "4758 & 3895" that are in the saem brackets.
I have attached the copy of the data for your reference.
I am expecting the results something like this:
712 0
713 0
714 0
1049 4758 3895 1
1050 4758 3895 1
1051 0
1052 0
1053 0
1054 4758 3895 1
1055 4758 3895 1
where "1" represent the number of counts.
I'm trying python code like this, but its not working.
I'm not familiar in python kindly advice.
Many Thanks
Balaji
I am having text file having huge data.
From the text file i would like to map the two numbers that are present in the same brackets and the values should not considered if they are present in different numbers.
say for example I want to map number "4758 & 3895" that are in the saem brackets.
I have attached the copy of the data for your reference.
I am expecting the results something like this:
712 0
713 0
714 0
1049 4758 3895 1
1050 4758 3895 1
1051 0
1052 0
1053 0
1054 4758 3895 1
1055 4758 3895 1
where "1" represent the number of counts.
I'm trying python code like this, but its not working.
Code:
def main():
#Open file for reading
infile = open('numbers.txt', 'r')
#Read the contents of the file into a list
number = infile.readlines()
#Convert each element into an int
index = 0
while index !=len(account_number):
number = [int(4758 3895) for num in number]
index +=1
#Get an the search value
search = raw_input('Enter a number to search for: ')
#Determine whether this record matches the search value.
if search in number:
print 'Number found.', search
else:
print 'The number was not found.'
#Close the file.
infile.close()
#Call the main function.
main()
Many Thanks
Balaji