Hello,I have a text file(below) with multiple columns, that I\'m finding difficu
ID: 3905027 • Letter: H
Question
Hello,I have a text file(below) with multiple columns, that I'm finding difficult to combine into one via a python script . There's 3 separate data's, where I'm trying to combine them with respect to FileY and FileX. Ideally, the finished product would have column headers [FileY, FileX, FidY, FidX, PSY, PSX, LEFT, TOP, RIGHT, BOTTOM]. This is just a small sample from the entire data, any help would be greatly appreciated!
Sensor: 2S_4289_SN10_tape
Date:6/15/2018 01:05:10.1900 PM
Step-Size: Y:195.0540 X:252.6130
Number of Steps: Y:37 X:31
Calibration: Y:10.8800 X:11.4500
FileY FileX PSY PSX
0.000000 0.000000 60941.000000 68251.000000
0.000000 1.000000 60940.194000 67998.388000
FileY FileX FidY FidX
0.000000 0.000000 88.354637 159.685562
0.000000 0.000000 88.214424 109.670059
0.000000 0.000000 88.183914 61.865841
0.000000 1.000000 88.640099 268.088898
0.000000 1.000000 88.489227 180.251328
FileY FileX LEFT TOP RIGHT BOTTOM
0.000000 0.000000 24.000000 26.000000 320.000000 240.000000
0.000000 1.000000 0.000000 25.000000 320.000000 240.000000
Explanation / Answer
There is a file with multiple columns. The sets of columns are
FileY FileX PSY PSX
.....................
.....................
FileY File X FidY FidX
..............................
...............................
FileY FileX LEFT TOP RIGHT BOTTOM
......................................
......................................
If above is the exact format of data , then we can list of lists for the first set of
data, similarly a list of second set of data and same for the third set of data. So we
will be having:
List1 [[FileY FileX PSY PSX],[--------------]]
List2 [[FileY File X FidY FidX],[--------------]]
List3 [[FileY FileX LEFT TOP RIGHT BOTTOM],[--------------]]
Now we can make a list3 by reading all the rows form the list and appending the data in
one row.
Say List = []
List.append(List1[i][0])
List.append(List1[i][1])
List.append(List1[i][2])
List.append(List1[i][3])
List.append(List2[i][2])
List.append(List2[i][3])
List.append(List3[i][2])
List.append(List3[i][3])
List.append(List3[i][4])
List.append(List3[i][5])
and then
List3.append(List)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.