kill(all)$

Maxima : Export from data 'Spreadsheet from LibreOffice ,Calc '
peter.vlasschaert@gmail.com, 16/01/2019

load packages (general)
====================

load("lrats")$

read data : from spreadsheet 'Calc ,LibreOffice')
------------------------------------------------------------------------
------------------------------------------------------------------------

info
------

Directory structure
================

maxima_userdir;

maxima_tempdir;

personal data : directory
=============================================

data :  Directory   =>  C:/Users/Chem1/Desktop/studie/
=============================================
open : ?  data    ' commming from ( libreOffice , 'Calc') '
----------------------------------------------------------------------------------
Maxima : Use "Tab " delimiter for data   'output' .
----------------------------------------------------------------------------------

 =============================================

1e)  read data file into Maxima
---------------------------------------------

website : "rosettacode"
====================

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

code : 'https://www.rosettacode.org/wiki/Read_a_file_line_by_line#Maxima'

readfile(name) := block(
   [v: [ ], f: openr(name), line],
   while stringp(line: readline(f)) do v: endcons(line, v),
   close(f),
   v
)$

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

rem : number of lines  ?  ' modification  readfile

rem : openr   ' Maxima command '
--------------------------------------------------

?  openr;

all lines  ( = txt file   'datah2alogtab.txt' )
----------------------------------------------------------

p1:a:readfile("C:/Users/Chem1/Desktop/studie/datah2alogtab.txt")$

first line   ( = txt file   'datah2alogtab.txt' )  =>  [1]
----------------------------------------------------------------------

p1a:a[1];

rem :
==================================================================================================================

a[1]  ? , predicate 'stringp' ?
=======================

p2:stringp(p1);

p2a:string(p1a);
p2b:stringp(p2a);

rem : readline : 'code' 
every line (read by :readline) = string , from *.txt

 ====================================================================================================================

2e) parse the string ( = first line)   'principles'
-----------------------------------------------------------------------------

a)  load package  ( = string manpulation)
==================================

load("stringproc")$

b)  take tokens
=============

p3:tokens(p1a);

rem : to extract tokens from p3
----------------------------------------------

p3a:ev(p3[2],float);

p3a1:stringp(p3a);

p3b:ev(p3[3],float);

p3b1:stringp(p3b);

c)  parse the string ( with use 'map' instruction)
=======================================

p4:map(parse_string,p3);

d) convert to floating point notation
==============================

p5:float(p4);

check p5:
========

p6:p5[2]+p5[3];

modification : readfile 'above'  ( 'rosseta code')
=======================================

readfilen(name) := block(
   [v: [ ], f: openr(name), line,n:0],
   while stringp(line: readline(f)) 
     do ( n:n+1,v: endcons(line, v)),     
   close(f),
   return([n,v])
)$

p7:readfilen("C:/Users/Chem1/Desktop/studie/datah2alogtab.txt");

1e) number of lines :  'datah2alogtab.txt'
==================================

p7a:p7[1];

2e) data                   :  'datah2alogtab.txt'
================================

p7b:p7[2];

a) first line : data
-------------------------

p8:p7b[1];

b) last line : data , ' see above '
----------------------------------------------

p8a:p7b[p7a];

How construct matrix 'q'  from  'p7b'   txt file :   'datah2alogtab.txt'
=======================================================

 dimension matrix : 'qq'
====================

number of  rows        : 'p7a '   (example : 23)
number of  columns :   ?

part  a)   ' number of columns'
======

p9:p7b[1];

p9a:tokens(p9);
p9b:length(p9a);

rem :  number of columns : 11

 result :
======

number of  rows        : 'p7a '   (example : 23)
number of  columns : 'p9b'    (example : 11)

part  b)   'construct Matrix Data'  from 'datah2alogtab.txt'
======

qq:matrix(
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0], 
 [0,0,0,0,0,0,0,0,0,0,0]
)$

for i:1 thru p7a 
do(      
    for j:1 thru p9b
     do
     (
       q6:p7b[i],
      q6a:tokens(q6),
      q6b:map(parse_string,q6a), 
      q6c:float(q6b),
      qq[i,j] :q6c[j] )
    );

see  :  Menu :Numeric :Set Displayed Precision
========================================

fpprintprec : 6;

Matrix  output
============

q7a:qq,number;

table form: (Matrix)
================

q7b:table_form(qq);