public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* GAWK Incorrect Data Display
@ 2020-12-19 23:34 Jason McGee
  2020-12-19 23:51 ` Jason McGee
  2020-12-20  0:16 ` Hans-Bernhard Bröker
  0 siblings, 2 replies; 4+ messages in thread
From: Jason McGee @ 2020-12-19 23:34 UTC (permalink / raw)
  To: cygwin

I confirmed there is not a problem with my code by comparing Cygwin against Gawk for Windows.

sp_array[++ sp_count] = d_quote "SP" d_quote ", " ticket "," d_quote type ", " volume ", " price ", " 0

I’m reading a file and writing the data to an array.

I’ve tried multiple variations are the problem is certainly in the Cygwin code.

The output is messed up if I have more than 7 variables.

Thanks

cygwin
$ gawk -f PROCESS_INGOT.awk ingot.txt
, 0                    01, 3686.3
                     0.01, 3686.3, 3680.0

Gawk for Windows
C:\cygwin64\home\trading_scripts>gawk -f PROCESS_INGOT.awk ingot.txt
"SP", 2183197,"SELL, 0.01, 3686.3, 0
"SP", 2183197,"SELL, 0.01, 3686.3, 3680.0


Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: GAWK Incorrect Data Display
  2020-12-19 23:34 GAWK Incorrect Data Display Jason McGee
@ 2020-12-19 23:51 ` Jason McGee
  2020-12-20  0:16 ` Hans-Bernhard Bröker
  1 sibling, 0 replies; 4+ messages in thread
From: Jason McGee @ 2020-12-19 23:51 UTC (permalink / raw)
  To: cygwin

Input Data
SP 2183197 SELL  0.01 3686.3
SP 2183197 SELL  0.01 3686.3 3680.0

I’m adding a 0 at the end,  if NF == 5


CORRECT
C:\cygwin64\home\trading_scripts>gawk -f PROCESS_INGOT.awk ingot.txt
"SP", 2183197,"SELL", 0.01, 3686.3, 0
"SP", 2183197,"SELL", 0.01, 3686.3, 3680.0


INCORRECT
gawk -f PROCESS_INGOT.awk ingot.txt
, 0", 2183197,"SELL", 0.01, 3686.3
"SP", 2183197,"SELL", 0.01, 3686.3, 3680.0

For some reason the last variable is transferred to the 1st position.


Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Jason McGee<mailto:goodmis@hotmail.com>
Sent: Saturday, December 19, 2020 6:34 PM
To: cygwin@cygwin.com<mailto:cygwin@cygwin.com>
Subject: GAWK Incorrect Data Display

I confirmed there is not a problem with my code by comparing Cygwin against Gawk for Windows.

sp_array[++ sp_count] = d_quote "SP" d_quote ", " ticket "," d_quote type ", " volume ", " price ", " 0

I’m reading a file and writing the data to an array.

I’ve tried multiple variations are the problem is certainly in the Cygwin code.

The output is messed up if I have more than 7 variables.

Thanks

cygwin
$ gawk -f PROCESS_INGOT.awk ingot.txt
, 0                    01, 3686.3
                     0.01, 3686.3, 3680.0

Gawk for Windows
C:\cygwin64\home\trading_scripts>gawk -f PROCESS_INGOT.awk ingot.txt
"SP", 2183197,"SELL, 0.01, 3686.3, 0
"SP", 2183197,"SELL, 0.01, 3686.3, 3680.0


Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GAWK Incorrect Data Display
  2020-12-19 23:34 GAWK Incorrect Data Display Jason McGee
  2020-12-19 23:51 ` Jason McGee
@ 2020-12-20  0:16 ` Hans-Bernhard Bröker
  2020-12-20 12:19   ` Norton Allen
  1 sibling, 1 reply; 4+ messages in thread
From: Hans-Bernhard Bröker @ 2020-12-20  0:16 UTC (permalink / raw)
  To: cygwin

Am 20.12.2020 um 00:34 schrieb Jason McGee via Cygwin:
> I confirmed there is not a problem with my code by comparing Cygwin against Gawk for Windows.

Your presentation of the problem is quite unclear, but the root cause is 
almost certainly not in the code, but in the data.

You're bound to be feeding Windows text files to a Unix tool.  You need 
to reformat the file to Unix format.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GAWK Incorrect Data Display
  2020-12-20  0:16 ` Hans-Bernhard Bröker
@ 2020-12-20 12:19   ` Norton Allen
  0 siblings, 0 replies; 4+ messages in thread
From: Norton Allen @ 2020-12-20 12:19 UTC (permalink / raw)
  To: cygwin

On 12/19/2020 7:16 PM, Hans-Bernhard Bröker wrote:
> Am 20.12.2020 um 00:34 schrieb Jason McGee via Cygwin:
>> I confirmed there is not a problem with my code by comparing Cygwin 
>> against Gawk for Windows.
>
> Your presentation of the problem is quite unclear, but the root cause 
> is almost certainly not in the code, but in the data.
>
> You're bound to be feeding Windows text files to a Unix tool.  You 
> need to reformat the file to Unix format.
>
I agree. The input likely has <cr><lf> line endings. Cygwin's gawk 
expects just <lf>, so the <cr> gets wrapped into the regular line text. 
Your ", 0" is not replacing the beginning of the line, it is 
overprinting it after the <cr>.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-20 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19 23:34 GAWK Incorrect Data Display Jason McGee
2020-12-19 23:51 ` Jason McGee
2020-12-20  0:16 ` Hans-Bernhard Bröker
2020-12-20 12:19   ` Norton Allen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).