[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf |
Date: |
Sat, 21 Nov 2015 18:02:45 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko |
URL:
<http://savannah.gnu.org/bugs/?46493>
Summary: Incorrect result from fscanf and scanf
Project: GNU Octave
Submitted by: None
Submitted on: Sat 21 Nov 2015 06:02:43 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Richard Suchland
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0
Operating System: Microsoft Windows
_______________________________________________________
Details:
While developing a script to read and plot weather station data from a CSV
file using fscanf, I got an unexpected result. After some analysis I tracked
it to fscanf reading a
particular reacord. It didn't seem to be a error in the data record and my
orignial thought was an issue with the size of the data (this occurred on the
4324th record in the
CSV file). Then I tried reading in the data as bytes converting to characters
and using sscanf, but got the same result. Then I cleared memory and executed
the following
standalone script which replicated the issue without the concern for memory.
The problem is that fscanf did not read all of the "bad" record data.
format short g
good = '"11/7/2015 6:24:00
PM","46","46","48","69.2","99","46.2","28.82126","13.5","11/8/2015 11:03:00
AM","6.835083","42","7.456454","270","9.320568"';
bad = '"11/7/2015 6:36:00
PM","47","48","48","69.6","96","47.8","28.82126","13.47","11/7/2015 5:08:00
PM","2.485485","48","1.864114","270","6.213712"';
frm = '"%i/%i/%i %i:%i:%i %2s" , "%i" , "%i" , "%i" , "%f" , "%i" , "%f" ,"%f"
, "%f" , "%i/%i/%i %i:%i:%i %2s" , "%f" , "%i" , "%f" , "%f", "%f"\n';
v = sscanf(good,frm)'
v =
Columns 1 through 14:
11 7 2015 6 24 0
80 77 46 46 48 69.2 99
46.2
Columns 15 through 28:
28.821 13.5 11 8 2015 11
3 0 65 77 6.8351 42 7.4565
270
Column 29:
9.3206
size(v)
ans =
1 29
v = sscanf(bad,frm)'
v =
Columns 1 through 14:
11 7 2015 6 36 0
80 77 47 48 48 69.6 96
47.8
Columns 15 through 21:
28.821 13.47 11 7 2015 5
0
>> size(v)
ans =
1 21
>>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?46493>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf,
anonymous <=
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf, Doug Stewart, 2015/11/21
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf, Doug Stewart, 2015/11/21
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf with %i format, Rik, 2015/11/22
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf with %i format, Richard Suchland, 2015/11/22
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf with %i format, Anselm Köhler, 2015/11/24
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf with %i format, Mike Miller, 2015/11/24
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf with %i format, Philip Nienhuis, 2015/11/25
- [Octave-bug-tracker] [bug #46493] Incorrect result from fscanf and scanf with %i format, Mike Miller, 2015/11/25