fw_arraytodbf - record empty - Resolved!

fw_arraytodbf - record empty - Resolved!

Postby Silvio.Falconi » Tue Mar 15, 2022 10:38 am

When I convert from a csv file to an array, the fw_ArrayToDBF (aData ,, bProgress) function inserts me an empty record, how do I avoid this

Code: Select all  Expand view  RUN
  local  csvfile:=".\csv\file.csv"
   local  cSymbol := ","
   local  cText := StrTran( MemoRead( csvfile ), CHR( 10 ), Chr(1) )
   local  aData := HB_ATokens( cText, Chr(1), .t., .t. )
   AEval( aData, { |c,i| c := StrTran( c, Chr(1), CRLF ), aData[ i ] := HB_ATokens( c, cSymbol, .t., .t. ) } )

      if len( ATail( aData ) ) < 2
           ASize( aData, Len( aData ) - 1 )
        endif
        Adel(aData,1)

       
          oDbf:= TDatabase():Open( , cPath+"mydb",DBFCDX", .T. )
         SET DELETED  ON

         oDbf:setorder(0)
         oDbf:gotop()
         oDbf:fw_ArrayToDBF( aData,,bProgress)


sample of csv
Code: Select all  Expand view  RUN
CodCausM,ContrMag,Controp,DescrCausM,EsclAggMag,Obsoleto,Storno,TipoCaus
00001,false,Fornitore,Acquisto,false,false,false,Acquisto
00002,false,Nessuna,Carico,false,false,false,Carico
00003,false,Cliente,C/Deposito,false,false,false,C/Deposito clienti
00004,false,Fornitore,C/Deposito da fornitori,false,false,false,C/Deposito fornitori
00005,false,Cliente,C/Lavoro da clienti,false,false,false,C/Lavoro attivo
00006,false,Fornitore,C/Lavoro,false,false,false,C/Lavoro passivo
00007,false,Cliente,Carico per riparazione,false,false,false,Carico
00008,false,Cliente,C/Visione,false,false,false,C/Terzi
00009,false,Nessuna,Inventario,false,false,false,Inventario
00011,false,Cliente,Reso da C/Visione,false,false,true,C/Terzi
00012,false,Cliente,Reso da cliente,false,false,true,Vendita
00013,false,Fornitore,Reso a fornitore,false,false,true,Acquisto
00014,false,Nessuna,Scarico,false,false,false,Scarico
00015,false,Cliente,Reso da C/Deposito clienti,false,false,true,C/Deposito clienti
00016,false,Fornitore,Reso da C/Deposito,false,false,true,C/Deposito fornitori
00017,false,Cliente,Reso da C/Lavoro,false,false,true,C/Lavoro attivo
00018,false,Fornitore,Reso da C/Lavoro fornitori,false,false,true,C/Lavoro passivo
00019,false,Cliente,Scarico da riparazione,false,false,false,Scarico
00020,false,Cliente,Vendita,false,false,false,Vendita
00021,true,Fornitore,Consegna a terzista,false,false,false,Scarico
00022,false,Cliente,Reso riparato,false,false,false,Vendita
00023,false,Cliente,Reso non riparato,false,false,false,Scarico
00024,false,Nessuna,Carico per rettifica giacenze,false,false,false,Carico
00025,false,Nessuna,Scarico per rettifica giacenze,false,false,false,Scarico
00026,false,Nessuna,Scarico per produzione,false,false,false,Scarico
00027,false,Nessuna,Carico per produzione,false,false,false,Carico
Last edited by Silvio.Falconi on Thu Mar 17, 2022 8:58 pm, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: fw_arraytodbf - record empty

Postby Silvio.Falconi » Wed Mar 16, 2022 7:59 am

Any solution Please ?

today I converted another file and I have the same problem see the picture

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: fw_arraytodbf - record empty

Postby nageswaragunupudi » Wed Mar 16, 2022 10:30 am

Instead of
Code: Select all  Expand view  RUN
       Adel(aData,1)
 

please try
Code: Select all  Expand view  RUN
       HB_Adel(aData,1, .t.)
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: fw_arraytodbf - record empty

Postby Silvio.Falconi » Wed Mar 16, 2022 11:40 am

nageswaragunupudi wrote:Instead of
Code: Select all  Expand view  RUN
       Adel(aData,1)
 

please try
Code: Select all  Expand view  RUN
       HB_Adel(aData,1, .t.)
 


Now it's good,thanks

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7063
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Antonio Linares, Google [Bot], Silvio.Falconi and 88 guests