Hi All,
I need obtein the CSV file with the ; separator en PB2019 R2, Could you help, please?
This is the code
choose case ls_extension
case 'CSV'
dw_1.Saveas(c:\file, CSV!, TRUE)
end choose
This is the example file, obtein now
GTIN,Serial Number,Expiration Date,CRYPTO,Purchase Order,CLN
97794990003924,100196,220721,1783,369947,L4612
97794990003924,100197,220721,1784,369947,L4644
thanks and regards,
Fernando.
thanks.
Fernando.
I agree with John .. write the CSV via a SaveAs() command and then Read it back into the PB App (or another PB App EXE) and replace the "," with ";". For super fast replacing, have a look at my "fn_replace_all" global function in my framework. Feel free to copy this GF into your App and use it. The framework is free and open source.
FYI: http://sourceforge.net/projects/stdfndclass/files/FrameWork/Integrated
Tip: for super large files, use the FileRead() command that grabs 32K chunks of a file at a time, replace & write that back out. Then grab the next 32K chunk. That will use very little memory. HTH
Regards ... Chris
thanks for this information.
I created this function.
/*function: f_dw_saveasformattedtext(dw_1, ls_filename, ';')
parameters: adw_dw(datawindow/datastore), as_filename (string), as_separator(string)
*/
long ll_row, ll_rows, ll_colcount, ll_colindex
string ls_colname, ls_coltype, ls_value, ls_lineval
int li_filenum
any la_anyval
long ll_row1, ll_rows1, ll_colcount1, ll_colindex1
string ls_colname1, ls_coltype1, ls_value1, ls_lineval1
int li_filenum1
any la_anyval1
ll_rows = adw_dw.rowcount()
ll_colcount = long(adw_dw.Describe("DataWindow.Column.Count"))
li_filenum = FileOpen(as_filename, LineMode!, Write!, LockWrite!, Append!)
if li_filenum = -1 or isnull(li_filenum) = true then
return -1
end if
ls_lineval1 = ''
for ll_colindex1 = 1 to ll_colcount
ls_colname1 = adw_dw.describe("#" + string(ll_colindex1) + ".DBName")
//ls_lineval1 = ls_colname1
if ll_colindex1 = 1 then
ls_lineval1 = ls_colname1
else
ls_lineval1 +=as_separator + ls_colname1
end if
next //rows
FileWrite(li_filenum, ls_lineval1)
for ll_row = 1 to ll_rows
ls_lineval = ''
for ll_colindex = 1 to ll_colcount
ls_colname = adw_dw.describe("#" + string(ll_colindex) + ".Name")
//ls_lineval += ls_colname + char(13)
ls_coltype = adw_dw.Describe ( ls_colname + ".ColType" )
CHOOSE CASE Lower ( Left ( ls_coltype , 5 ) )
CASE "char(", "char","strin" // CHARACTER DATATYPE
la_anyval = adw_dw.GetItemString ( ll_row, ls_colname )
CASE "date" // DATE DATATYPE
la_anyval = adw_dw.GetItemDate ( ll_row, ls_colname )
CASE "datet" // DATETIME DATATYPE
la_anyval = adw_dw.GetItemDateTime ( ll_row, ls_colname )
CASE "decim" // DECIMAL DATATYPE
la_anyval = adw_dw.GetItemDecimal ( ll_row, ls_colname )
CASE "numbe", "long", "ulong", "real", "int" // NUMBER DATATYPE
la_anyval = adw_dw.GetItemNumber ( ll_row, ls_colname )
CASE "time", "times" // TIME DATATYPE
la_anyval = adw_dw.GetItemTime ( ll_row, ls_colname )
CASE ELSE
SetNull ( la_anyval )
END CHOOSE
ls_value = string(la_anyval)
if trim(ls_lineval) = '' then
ls_lineval = ls_value
else
ls_lineval += as_separator + ls_value
end if
next //columns
FileWrite(li_filenum, ls_lineval)
next //rows
return 1
regards,
Fernando.