Hi Ponnumani.
I would like to make a number of clarifications:
- <FONT COLOR="#000080">VALUELIST </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"A A- B B- O"</FONT> -> <FONT COLOR="#000080">VALUELIST </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">" A A- B B- O"</FONT>
- it is necessary to consider the order of the fields in the global on the basis of Storage. For example, I have following Storage:
<Data name="samplexlsconversionDefaultData"> <Value name="1"> <Value>%%CLASSNAME</Value> </Value> <Value name="2"> <Value>name</Value> </Value> <Value name="3"> <Value>DOB</Value> </Value> <Value name="4"> <Value>address</Value> </Value> <Value name="5"> <Value>PhoneNumber</Value> </Value> <Value name="6"> <Value>BloodGroup</Value> </Value> </Data>
- need to add check for the presence of double quotes in strings, e.g. bla"bla
- the date format for CSV should not be in the internal Caché format, because the date 37893 to users of other system/DBMS nothing says unlike e.g. 1944-09-30.
Class User.samplexlsconversion Extends (%Persistent, %Populate)
{
</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">name </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;
</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DOB </FONT><FONT COLOR="#000080">As %Date</FONT><FONT COLOR="#000000">;
</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">address </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;
</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">PhoneNumber </FONT><FONT COLOR="#000080">As %Numeric</FONT><FONT COLOR="#000000">;
</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">BloodGroup </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">VALUELIST </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">" A A- B B- O"</FONT><FONT COLOR="#000000">);
</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">TestExport2CSV()
{
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">%KillExtent</FONT><FONT COLOR="#000000">()
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">Populate</FONT><FONT COLOR="#000000">(1000)
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">=..</FONT><FONT COLOR="#0000ff">%OpenId</FONT><FONT COLOR="#000000">(1)
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">name</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34)
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Save</FONT><FONT COLOR="#000000">()
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">=..</FONT><FONT COLOR="#0000ff">%OpenId</FONT><FONT COLOR="#000000">(2)
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">name</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34)</FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">name</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34)
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">tmp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Save</FONT><FONT COLOR="#000000">()
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%SQL.Export.Mgr</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">FileName </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008000">"c:\Temp\test.csv"
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">ClassName </FONT><FONT COLOR="#000000">= ..</FONT><FONT COLOR="#0000ff">%ClassName</FONT><FONT COLOR="#000000">(1)
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TableName </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#0000ff">$$$CLASSsqltablename</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$$$gWRK</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">ClassName</FONT><FONT COLOR="#000000">)
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Delimiter </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008000">","
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">StringQuote </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(34)
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DateFormat </FONT><FONT COLOR="#000000">= 3
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TimeFormat </FONT><FONT COLOR="#000000">= 1
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TimeStampFormat </FONT><FONT COLOR="#000000">= 1
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">NoCheck </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#0000ff">$$$YES
s </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">HasHeaders </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#0000ff">$$$YES
s </FONT><FONT COLOR="#800000">cols</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Name:S;Address:S;PhoneNumber:N;BloodGroup:S;DOB:D"
</FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#0000ff">$l</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">cols</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">";"</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">{
</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">cols</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">";"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">)
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">ColumnNames</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Insert</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">":"</FONT><FONT COLOR="#000000">,1))
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">ColumnTypes</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Insert</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">":"</FONT><FONT COLOR="#000000">,2))
</FONT><FONT COLOR="#800080">}
</FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">mgr</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Export</FONT><FONT COLOR="#000000">()
}
}</FONT>
- Log in to post comments