I tried to open a .txt file as an array in python, so I can operate on the elements within. The .txt file (abc.txt) looks something like this.
AL192012, TONY, 20,
20121021, 1800, , LO, 20.1N, 50.8W, 25, 1011,
20121022, 0000, , LO, 20.4N, 51.2W, 25, 1011,
20121022, 0600, , LO, 20.8N, 51.5W, 25, 1010,
20121022, 1200, , LO, 21.3N, 51.7W, 30, 1009,
AL182012, SANDY, 45,
20121021, 1800, , LO, 14.3N, 77.4W, 25, 1006,
20121022, 0000, , LO, 13.9N, 77.8W, 25, 1005,
20121022, 0600, , LO, 13.5N, 78.2W, 25, 1003,
20121022, 1200, , TD, 13.1N, 78.6W, 30, 1002,
I have tried pd.read_csv('abc.txt')
, loadtxt("abc.txt")
and genfromtxt("abc.txt")
. But they only generated array with three columns, probably because the first row only had three columns. But I want it to have the same eight columns as the .txt file. Is this possible? Thanks!