Search Results

Search: Posts Made By: nans
2,146
Posted By RudiC
Tryawk ' NR > 1 {for (i=5; i<=NF; i++) {n =...
Tryawk '
NR > 1 {for (i=5; i<=NF; i++) {n = split ($i, T, ",")
for (j=1; j<=n; j++) SUM += T[j]
$i = SUM/n
...
1,677
Posted By Chubler_XL
Here is my attempt, I've only replace fields...
Here is my attempt, I've only replace fields that start with two or more ., characters as you seem to have fields ending with these characters in your desired output:

awk '
FNR==1 {
if...
2,065
Posted By RudiC
Try awk ' NR == 1 {HD = $0 ...
Try
awk '
NR == 1 {HD = $0
next
}
{split ($2, T, "\.")
OUTF = T[1] ".txt"
if (!(T[1] in HDPR)) ...
2,065
Posted By Scrutinizer
True, not an error, but perhaps it is interesting...
True, not an error, but perhaps it is interesting to ponder why exactly the warning was issued here.

The reason that the escape \ does not matter in this case is that a single character, other...
1,152
Posted By Scrutinizer
Hi, try: awk ' { n=split($6,F,/,/) ...
Hi, try:
awk '
{
n=split($6,F,/,/)
split($7,G,/,/)
split($8,H,/,/)
$6=$7=$8=""
for(i=1; i<=n; i++) {
s=(i>1)?",":""
$6=$6 s F[i] ":" G[i]
$7=$7 s...
1,152
Posted By RudiC
Like so: awk ' {n = split ($6, T,...
Like so:
awk '
{n = split ($6, T, ",")
m = split ($7, V, ",")
l = split ($8, W, ",")
$6 = $7 = $8 = ""
for (i=1; i<=n; i++) {$6 = $6 T[i] ":" V[i]...
3,923
Posted By RavinderSingh13
Hello nans, Could you please try following...
Hello nans,

Could you please try following and let me know if this helps you.

awk '
FNR==NR && FNR==1{
first_file=FILENAME
}
FNR==1 && val{
close(val)
}
FNR==NR{
val=FILENAME;...
3,923
Posted By RudiC
Try also (for the fun of it) awk ' FNR == 1 ...
Try also (for the fun of it)
awk '
FNR == 1 {FC++
}
NR == 1 {AC = ARGC
ARGV[ARGC++] = FILENAME
...
3,923
Posted By RavinderSingh13
Hello nans, Could you please try following...
Hello nans,

Could you please try following and let me know if this helps you.

awk 'FNR==NR && FNR==1{first_file=FILENAME} FNR==1 && val{close(val)} FNR==1{val=FILENAME}...
Forum: Programming 07-05-2017
19,951
Posted By durden_tyler
Congratulations! while cell_pos.value: ...
Congratulations!

while cell_pos.value:
will run the "while" loop as long as cell_pos.value is True that is, it is non-empty.

In order to check "all of cells E, G, F are empty" we use the...
Forum: Programming 07-04-2017
19,951
Posted By durden_tyler
Yes, much better. Now you are able to capture...
Yes, much better.
Now you are able to capture the values of E,G,F columns of every row you are going through.

As for saving the results, here are a few things you need to know about "openpyxl"...
Forum: Programming 07-03-2017
19,951
Posted By durden_tyler
No, it should not. It will not. No...
No, it should not.
It will not.
No programming language will do that for you.
Golden rule of programming => a programming language will only do what you tell it to do. It will not do anything on...
Forum: Programming 07-03-2017
19,951
Posted By durden_tyler
Ok, that's more descriptive now. So the numbers...
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,...
Forum: Programming 06-30-2017
19,951
Posted By durden_tyler
Print the value of "cpos" inside the "while"...
Print the value of "cpos" inside the "while" loop.
It is the same every time.
That's the reason for the infinite loop.
You need the value of "cpos" to change in every iteration of the loop.
Forum: Programming 06-29-2017
19,951
Posted By durden_tyler
That's because the "while" statement went into...
That's because the "while" statement went into what is called an "infinite loop".
That's because "cpos" is always True everytime it is checked.
[ It means that "cpos" always has a value everytime...
Forum: Programming 06-28-2017
19,951
Posted By durden_tyler
b) You did not tell Python to go beyond row 4!...
b) You did not tell Python to go beyond row 4! That's why it did not read beyond row 4.

The earlier iterations of this program had the "while" statement in them, which you removed. That "while"...
Forum: Programming 06-27-2017
19,951
Posted By durden_tyler
You form 'E4' first and get its cell value. ...
You form 'E4' first and get its cell value.
Then you form 'G4' and get its cell value.
And then do the same for 'F4'.
Then you form "Scores" namedtuple using the cell values of 'E4', 'G4' and...
Forum: Programming 06-27-2017
19,951
Posted By durden_tyler
1) Remove the parameter, not the function call....
1) Remove the parameter, not the function call. In other words, do call the function, but don't pass any parameter to it.

2) Change the signature of the function so that it does not accept any...
Forum: Programming 06-27-2017
19,951
Posted By durden_tyler
I haven't gone through the entire code yet, and...
I haven't gone through the entire code yet, and it might be tricky to test your code since I don't have pandas, but let me answer your question about the function call.



The replace() function...
Forum: Programming 06-26-2017
19,951
Posted By durden_tyler
My hunch is that you are looking at the wrong...
My hunch is that you are looking at the wrong column.
If your "pos_col_no" is "F" and "row_no" is 4, then the code will look at cells F4, F5, F6, F7, F8, .... and check if they are keys of...
Forum: Programming 06-26-2017
19,951
Posted By durden_tyler
You are getting the "list has no attribute...
You are getting the "list has no attribute rstrip" error because you are trying to use the "rstrip()" function on the list (or array) called "line".

The "rstrip('\n')" function removes the...
Forum: Programming 06-23-2017
19,951
Posted By durden_tyler
Hmm... the indentation seems a bit awry. ...
Hmm... the indentation seems a bit awry.



Here's my code for reference. Check the indentation level and the comments:


# Subroutines
def get_text_data(txt_filename):
dict_pos = {}...
Forum: Programming 06-23-2017
19,951
Posted By durden_tyler
Just a quick observation: the name of the text...
Just a quick observation: the name of the text file inside your zip file is "scores.txt". The name of the Excel file inside your zip file is "S12.xlsx".
Now, the line in bold red color in your...
Forum: Programming 06-22-2017
19,951
Posted By durden_tyler
Here's some code that you'd like to try. ...
Here's some code that you'd like to try.


#!python
import os
from openpyxl import load_workbook
from datetime import datetime

# Variables
sheet_directory = r'<path_of_Excel_files>'...
Forum: Programming 06-30-2017
19,951
Posted By durden_tyler
Yes, "cpos" is inside the while loop. But is it...
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...
Showing results 1 to 25 of 45

 
All times are GMT -4. The time now is 12:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy