close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#371 closed enhancement (fixed)

export of data of a set-table

Reported by: imendez Owned by: Víctor de Buen Remiro
Priority: normal Milestone:
Component: SetAlgebra Version: head
Severity: minor Keywords:
Cc: pmguillem

Description

Hi,

I propose an improvement of the export function BSTFile, including a couple of
new (optional) arguments indicating the rows and columns separator characters.

For example, this code:

Set BSTFile( [[1,2?, 3,4,5? ]], "c:/kk1.bst");
Set BSTFile(NumOrdSt(1,2,3,4), NumOrdSt(5,6,7,8) ?, "c:/kk2.bst");

write in a file two SetOfSet of numbers, the first without structure and with
different number of elements in its rows:
Ex#1:
1.0000000000;2.0000000000;
3.0000000000;4.0000000000;5.0000000000;
Ex#2:
NumOrdSt;Mult_1;Mult_2;Mult_3;Mult_4;
;1.0000000000;2.0000000000;3.0000000000;4.0000000000;
;5.0000000000;6.0000000000;7.0000000000;8.0000000000;

What I propose is adding two new arguments:

Set BSTFile(Set s, Text file [, Text colSeparator = ";", Text rowSeparator = "\n"])

Above examples would be written as:
Set BSTFile( [[1,2?, 3,4,5? ]], "c:/kk1.bst", "|", "@");
Set BSTFile(NumOrdSt(1,2,3,4), NumOrdSt(5,6,7,8) ?, "c:/kk2.bst", "|", "@");

and the new result would be:
Ex#1:
1.0000000000|2.0000000000|@3.0000000000|4.0000000000|5.0000000000|
Ex#2:
NumOrdSt|Mult_1;Mult_2|Mult_3|Mult_4|@;1.0000000000|2.0000000000|3.0000000000;4.0000000000|@;5.0000000000|6.0000000000|7.0000000000;8.0000000000|

Regards.

Change History (5)

comment:1 Changed 19 years ago by Víctor de Buen Remiro

Owner: changed from danirus to Víctor de Buen Remiro

comment:2 Changed 19 years ago by Víctor de Buen Remiro

Resolution: fixed
Status: newclosed

Your proposal has been extrapolated to cover the family of ASCII file saving
functions, it's to say: BSTFile, BMTFile, BDTFile and StatFile. Argments for all
them have been extended to

(Set set

[,

Text fileName=\"Std\",
Text header=\"_DEFAULT_HEADER_\",
Real rewrite=TRUE,
Text colSeparator = \";\",
Text rowSeparator = \"
n\"

]

)

If no fileName is specified standard output "Std" will be used.

You can specify a header string that will be written at first line. If header
is "_DEFAULT_HEADER_" then default header for each function will be used if it has
sense. If header is "" no header will be written.

If you want to append results to an existant file use rewrite=FALSE

You can specify any column and row separators.

Results only will be readable by TOL, when this feature were available, if default
parameters are used.


bug_371/test.tol : Test that bug 371 has been solved and shows samples of
functions using new argument list in different non standard ways

Structure to test BSTFile
Struct test_struct
{

Real a_,
Real b_

};

Rewrites a new file using default header and tabulator "\t" as column
separator. Last one that has no "\t" but just row separator "\n"
Set BSTFile(
[[

test_struct(1,2),
test_struct(3,4)

]],"test_01.txt","_DEFAULT_HEADER_",1,"\t","\n");

Appends to existing file without header and the same separators
Set BSTFile(
[[

test_struct(5,6),
test_struct(7,8)

]],"test_01.txt","",0,"\t","\n");

Time series to test BDTFile and StatFile
Serie s1 = SubSer(Gaussian( 0,1,C),y2005,y2005m12d31);
Serie s2 = SubSer(Gaussian(10,1,C),y2005,y2005m12d31);
Serie s3 = SubSer(Gaussian( 0,1,C),y2006,y2006m12d31);
Serie s4 = SubSer(Gaussian(10,1,C),y2006,y2006m12d31);

Rewrites a new file using specific header and ";" as column separator. Last
one that has row separator ";\n"
Set BDTFile(s1,s2?,"test_02.bdt","C;S_1_3;S_2_4");
Appends to existing file without header and the same separators
Set BDTFile(s3,s4?,"test_02.bdt","",0,";",";\n");

Rewrites a new file using default header and "|" as column separator. Last
one that has row separator "\n"
Set StatFile(s1,s2?,"test_03.csv","_DEFAULT_HEADER_",1,";","\n");
Appends to existing file without header and the same separators
Set StatFile(s3,s4?,"test_03.csv","",0,";","\n");

comment:3 Changed 19 years ago by Víctor de Buen Remiro

Cc: pmguillem added

comment:4 Changed 19 years ago by Víctor de Buen Remiro

* Bug 313 has been marked as a duplicate of this bug. *

comment:5 Changed 18 years ago by Víctor de Buen Remiro

bug_file_loc: http://cvs.tol-project.org/viewcvs.cgi/tol_tests/tol/Bugzilla/bug_000371
Note: See TracTickets for help on using tickets.