Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ICsv - GetRowMS - and multistring
#2
Macro ICsv row str
Code:
Copy      Help
ICsv icsv1=CreateCsv(1)
str s1=
;a1,b1,c1
;a2,b2,c2
;a3,b3,c3
icsv1.FromString(s1)

int nr=icsv1.RowCount
int nc=icsv1.ColumnCount

ICsv icsv2=CreateCsv(1)

;???? declaration for multistring transfer row holder. Real variable decl WITHOUT using magical _s ????
str ms

int r c
for r 0 nr
,;;.......
,icsv1.GetRowMS(r ms)
,;;.......
,icsv2.AddRowMS(-1 nc ms)
,;;.......

;results
str s2; icsv2.ToString(s2); out s2

Reading/writing in multistring format is fast. But multistring format in most cases is inconvenient if you want to do something more with row data (read/change cells). Because all row cells are in single variable, and would need to parse it.

Here is example with array as a row holder.
Macro ICsv row ARRAY
Code:
Copy      Help
ICsv icsv1=CreateCsv(1)
str s1=
;a1,b1,c1
;a2,b2,c2
;a3,b3,c3
icsv1.FromString(s1)

int nr=icsv1.RowCount
int nc=icsv1.ColumnCount

ICsv icsv2=CreateCsv(1)

;???? declaration for multistring transfer row holder. Real variable decl WITHOUT using magical _s ????
ARRAY(str) a.create(nc)

int r c
for r 0 nr
,;;.......
,for(c 0 nc) a[c]=icsv1.Cell(r c)
,;;.......
,icsv2.AddRowSA(-1 nc &a[0])
,;;.......

;results
str s2; icsv2.ToString(s2); out s2


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)