I am using the following code to import data in Python:
one=[]
two=[]
three=[]
four=[]
five=[]
six=[]
x=0
for line in open('text.txt', 'r'):
if x==2:
column0, column1, column2, column3, column4, column5 = line.split(',')
else:
column0, column1, column2, column3, column4, column5 = line.split(' ')
one.append(column0)
two.append(column1)
three.append(column2)
four.append(column3)
five.append(column4)
six.append(column5)
x=x+1
This code imports this text file:
1 2 3 4 5 6
1 2 3 4 5 6
1,2,3,4,5,6
1 2 3 4 5 6
1 2 3 4 5 6
But I am having so much trouble with how to import the following
1 2 3 4 5 6
1 2 3 4 5 6
1,2,3,
4,5,6
1 2 3 4 5 6
1 2 3 4 5 6
Even though the data has a break on the third line I want it to import the same way as the first text file. I tried importing by row and then using the number of variables for the third row but I could not get it to work.
Does anyone know of any resources or examples or that can help? Thanks!