Antonio Linares wrote:Dear Silvio,
Mr. Rao will help you on this. He is the right one to do it
thanks, in the example I had I didn't have to delete the first line, now I have a file that in the first line of the csv file I have the database fields and I was able to delete with adel (adata, 1) but later when I use oDbf: fw_ArrayToDBF (aData, , bProgress) to save aData in the dbf archive, the procedure inserts a first empty record and then in any case inserts all the other records
for a sample here pubblish a little csv fille
- Code: Select all Expand view
CodUM,DescrUM,Molt,NumDec,Tipo,CodDescrUM
CF10,Confezione 10 pezzi,10,0,Numero,CF10 - Confezione 10 pezzi
CF2,Confezione 2 pezzi,2,0,Numero,CF2 - Confezione 2 pezzi
CF20,Confezione 20 pezzi,20,0,Numero,CF20 - Confezione 20 pezzi
CF24,Confezione 24 pezzi,24,0,Numero,CF24 - Confezione 24 pezzi
CF3,Confezione 3 pezzi,3,0,Numero,CF3 - Confezione 3 pezzi
CF4,Confezione 4 pezzi,4,0,Numero,CF4 - Confezione 4 pezzi
CF5,Confezione 5 pezzi,5,0,Numero,CF5 - Confezione 5 pezzi
CF6,Confezione 6 pezzi,6,0,Numero,CF6 - Confezione 6 pezzi
KG,Chilogrammi,1,3,Peso,KG - Chilogrammi
LT,Litri,1,3,Volume,LT - Litri
MC,Metri cubi,1,3,Volume,MC - Metri cubi
MQ,Metri quadri,1,3,Lunghezza,MQ - Metri quadri
MT,Metri,1,3,Lunghezza,MT - Metri
NR,Numero,1,0,Numero,NR - Numero
PZ,Pezzi,1,0,Numero,PZ - Pezzi
FieldsCodUM (C, 4, 0)
DescrUM (C, 86, 0)
Molt (N, 13, 6)
NumDec (N, 1, 0)
Tipo (C, 10, 0)
CodDescrUM (C, 86, 0)
local csvfile:=".\csv\test.csv"
Local cSymbol := ","
Local cText := StrTran( MemoRead( csvfile ), CHR( 10 ), Chr(1) )
Local aData := HB_ATokens( cText, Chr(1), .t., .t. )
// load csv to aData
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) // erase first line
// save to dbf
oMisura:= TDatabase():Open( , cPath+"Unitamisura", "DBFCDX", .T. )
SET DELETED ON
oMisura:setorder(0)
oMisura:gotop()
oMisura:fw_ArrayToDBF( aData,,bProgress)
DbCloseAll()
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