[Scilab-users] Reading numericaldata from txt file containing headlines

Jens Simon Strom j.s.strom at hslmg.de
Fri Mar 3 16:24:26 CET 2017


Thanks Amanda, that helps.

In the meantime I have found an alternate way by editing the text file:
Move the leading text lines to the end of the data colums.
Append  a hint after the first data line that there is information below.
Use
x=read(file,r,c)
where r and c define the row and colum number of the numerical data. 
That works even for my chaotic data format wherein different numbers of 
blanks and tabs in each line  separate the data.

Regards, Jens

-------------------------------------------------------------------------------------------------------------------------------------------------------


Am 03.03.2017 13:42, schrieb Amanda Osvaldo:
> Hi,
>
> if your data it's tabular, in another words, you can open it in Excel 
> or Libre Office Calc like you whant to do.
>
> You should be able to read in the same way with csvRead, however you 
> need to adjust the parameters
>
> Something like:
>
> [M,comments] =csvRead('myfile.txt','	',[],[],[],[],[],5);
>
> Note that ' ' need to be the same separator in your text file.
> *May be*  it can be a TAB (the key in keyboard) or a simple space, you need try or open your file and check it.
>
> And the 5 value it's to ignore the first 5 lines.
>
> https://help.scilab.org/docs/6.0.0/en_US/csvRead.html
> Is that what you are looking for ?
>
> -- Amanda Osvaldo
>
> On Fri, 2017-03-03 at 13:09 +0100, Jens Simon Strom wrote:
>> Hi,
>> with
>> x=read(file,-1,2)
>> I can read the data from a text file containing e. g.
>>
>> 1  2.12       First line of text file
>> 2.12   3.2
>> 3 2
>> 4  2
>> 5 2.
>> 6     2
>> 7 2
>>             Last line empty
>>
>> What can I do to read only the numbers from a text file like
>>
>> Header 1     First line of text file
>> Header 2
>>
>>
>> 1 2.12
>> 2.12 3.2
>> 3 2
>> 4 2
>> 5 2.
>> 6 2
>> 7 2
>>             Last line empty
>>
>> where the data start in the 5th line?
>>
>> Regards, Jens
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org  <mailto:users at lists.scilab.org>
>> http://lists.scilab.org/mailman/listinfo/users
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170303/5550338e/attachment.htm>


More information about the users mailing list