Yes, "cpos" is inside the while loop. But is it changing every time the "row_no" changes?
Do this:
1) Print "row_no" and "cpos". (You are printing cpos, so print row_no as well.)
2) Then compare the values of "row_no", "cpos" printed by your Python program with the data in your Excel spreadsheet.
For row_no = 4, the Python "cpos" should reflect Excel's cells E4, G4, F4
For row_no = 5, the Python "cpos" should reflect Excel's cells E5, G5, F5
For row_no = 6, the Python "cpos" should reflect Excel's cells E6, G6, F6
...
Try it and see if that's what is actually happening.
If not, then that is wrong and the cause for the infinite loop.
This User Gave Thanks to durden_tyler For This Post:
Im not able to print the row no either as
goes into a loop. I dont know how to proceed.
Don't print "dict_pos[cpos]". It was commented out in your earlier code anyway. Remove it or comment it out.
Simply print row_no and cpos.
Uncomment the "#print cpos" line.
when I do that, then the values of cpos goes into a loop
Ok, that's more descriptive now.
So the numbers you see: 2921689, 2921690, 2921691 are the row numbers of your spreadsheet.
The "Scores" value is the Python namedtuple value corresponding to (73, 'G', 'A').
Now in your Excel spreadsheet, (73, 'G', 'A') are the values of (E4, G4, F4), most likely <== can you confirm that?
So what's happening is that you are going to row_no = 5, but cpos is still equal to "Scores(pos=E4, alt=G4, ref=F4)". When you are in row_no = 5, you need to recalculate cpos by picking up values from E5, G5, F5.
Same thing with row_no = 6, 7, 8, .... 2921689, 2921690, ...
In case the output is being printed too fast, change the condition "while cpos:" to "while row_no <= 10:".
---------- Post updated at 08:16 AM ---------- Previous update was at 08:10 AM ----------
Here is what your output should look like:
This is based on the "S12.xlsx" you posted earlier in this thread.
This User Gave Thanks to durden_tyler For This Post:
Correct, those values are of (E4, G4, F4). But with "row_no += 1", shouldnt it pick up the values from the next row ? I thought this while loop meant 'go to row 4, if the row matches the score from the dictionary, print the value or else print unknown and then go on to the next row and do the same' How would I recalculate the values in a loop for all rows ?
Source Code of the original script is down below please run the script and try to solve this problem
this is my data and I want it column wise
2019-03-20 13:00:00:000
2019-03-20 15:00:00:000
1
Operating System
LAB
0
1
1
1
1
1
1
1
1
1
0
1 (5 Replies)
Hi experts -
I'm relatively new to python, but I have an requirement to automate getting a file from a WebLib server using an API.
The file I'm requesting from this sever is an excel spreadsheet (.xlsx).
I get a valid response back via an xml doc from the server.
In this xml file I get... (8 Replies)
Hi,
I have a requirement to append = in particular row in csv file. Data in csv is as follow:
row1,a,a,a
row2,b,b,b
row3,c,c,c
row4,d,d,d
csv should be modified at row3 and no. of columns are not fixed but rows are. output should be as:
row1,a,a,a
row2,b,b,b
row3,=c,=c,=c... (2 Replies)
Hi All,
Input.txt
KGO
Id "003"
..........
..........
Par "CPara"
BIN RECGET
Name "DIR_PATH"
Prompt "DIR_PATH"
END RECGET
KGO
............
..........
...............
KGO
Id "077"
..........
.......... (7 Replies)
I have a text file where I want to append a column of numbers in ascending orders.
Input:
57 abc
25 def
32 ghi
54 jkl
Output:57 abc
57 abc 1
25 def 2
32 ghi 3
54 jkl 4
How do I go about doing that? Thanks! (11 Replies)
Hi, i want to add another column to existing files containing strings and need to have the final output as a csv file. i have quite a number of files, each with varying number of rows and i need to append the string "test" for all the valid rows for each file. my sample raw files looks like this... (8 Replies)
Hi ,
I have a file with a running sequence number. I need to append a date value mmdd format on to the first column.
for e.g.: The file contains records as
001 abc
002 cde
003 edf
004 fgh
005 hik
The output should be
1111001 abc
1111002 cde
1111003 edf
1111004 ... (1 Reply)
Hi all,
I have two files with the same number of lines
the first file is a.dat and looks like
0.000 1.000
1.000 2.000
...
the fields are tab separated
the second file is b.dat and looks like
1.2347 0.546
2.3564 0.321
...
the fields are tab separated
I would like to have a file c.dat... (4 Replies)
Hi , I have the below file with 6 columns.I want to append 'File1' as the 1 column to the file. i have the sample code .It is not working . can u please correct this or make new one .....
awk 'print {'File1',$1,$2,$3,$4,$5,$6}' Source_File> Result_File
Source_File:... (6 Replies)
It appears that this has been asked and answered in similar fashions previously, but I am still unsure how to approach this.
I have two files containing user information:
fileA
ttim:/home/ttim:Tiny Tim:632
ppinto:/home/ppinto:Pam Pinto:633
fileB
ttim:xkfgjkd*&#^jhdfh... (3 Replies)