[Scilab-users] using csvRead

Samuel Gougeon sgougeon at free.fr
Sat Oct 15 23:40:37 CEST 2016


Le 15/10/2016 21:16, Samuel Gougeon a écrit :
> Hello Philipp,
>
> Le 14/10/2016 00:08, Philipp Mühlmann a écrit :
>> Dear Scilab users,
>>
>> having a data file (*.cvs) containg following format:
>>
>>
>> HEADER-Line
>> dd.mm.yyyy, HH:MM:SS.MS <http://SS.MS>, value01, value02
>>
>> dd = day
>> mm = month
>> yyyy = year
>>
>> HH = hour
>> MM = minute
>> SS = second
>> Ms = milli second
>>
>> ValueXY = numerical value
>>
>> Is it possible to use cvsRead in such a way to define the separator 
>> beeing ',' and ':' at the same time?
> .
> Yes and no: Yes because each character of the "separator" option is 
> (sometimes) considered as a
> separator. And no, because it sometimes fails.
> I was designing an example to add to the csvRead() page, when a found 
> this bug:
>
> --> mputl("12.08.2016, 13:54:18.45, 3.145, 548.4", TMPDIR+"/test.csv")
>
> --> r = "''"+csvRead("test.csv","8.",[],"string")+"''"
>  r  =
> !'12'  '0'  '2016, 13:54:1'  '45, 3'  '145, 54'  '4'  !
> --> // it works: both "8" and "." are *separately* considered as 
> separators
>
> --> // now trying with "," and ":":
> --> r = "''"+csvRead("test.csv",",:", [], "string")+"''"
> --> r = "''"+csvRead("test.csv",",:", [], "string")+"''"
>  r  =
>  '12.08.2016, 13:54:18.45, 3.145, 548.4'
> --> // The row is kept as is: no splitting!
> --> // We could expect: ['12.08.2016' ' 13' '54' '18.45' ' 3.145' ' 
> 548.4']
> --> //  (with leading spaces, since they are not set as separators)
> -->
>
> There are already 10 pending reported bugs about csvRead(). One more.
Report : http://bugzilla.scilab.org/14809

Each char of a separator with length > 1 is considered a specific 
separator only if the whole separator pattern is met in the read row. 
Otherwise, no splitting is done. Hence,
--> r = csvRead(TMPDIR+"test.csv","8.",[],"string") // splits the 
"12.08.2016" row, while
-->r = csvRead(TMPDIR+"test.csv",".8",[],"string") // does not!

Samuel Gougeon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161015/13491fa5/attachment.htm>


More information about the users mailing list