I am storing data from a file into a list to analyse it for patterns. My intention is to be able to read a txt or csv file. I am struggling to find a way to analyse the information from the original list that is stored from the file to identify integers within that list.
I have tried the .isdigit() builtin method but that is returning False although the 'data' list is numbers, comma's and a some string's. The 'data' list does not have string numbers just integers.
It works as expected until the noCheck function, which just prints the ValueError.
data = []
IntData = []
def analyse():
try:
openfile = input('Enter file path: ')
with open(openfile) as f:
read = f.read()
data.append(read)
print(data)
next = input('Press any Key to continue..')
if next == '':
noCheck()
except FileNotFoundError:
print('No File Found')
def noCheck():
for number in data:
try:
IntData.append(int(number))
print(IntData)
except ValueError:
print('No numbers found')
analyse()
Any help is greatly appreciated
EDIT: This is the data in the txt file:
08,30,34,44,45,57\n09,18,20,42,43,46\n14,19,30,45,48,58\n02,04,17,28,37,45\n14,18,23,28,36,37\n05,08,40,41,43,45\n18,25,29,32,35,58\n04,10,11,17,53,54\n24,30,44,50,56,57