sample of storico.txt
- Code: Select all Expand view
1939/01/07 BA 58 22 47 49 69
1939/01/07 FI 27 57 81 43 61
1939/01/07 MI 40 38 57 67 7
1939/01/07 NA 85 44 48 88 55
1939/01/07 PA 73 80 39 38 57
1939/01/07 RM 73 24 4 39 22
1939/01/07 TO 19 43 10 31 27
1939/01/07 VE 9 43 61 14 75
the fields of dbf
- Code: Select all Expand view
- local aFields := { { "DATA" , "D", 8, 0 },;
{ "RUOTA", "C", 2, 0 },;
{ "N1" , "N", 2, 0 },;
{ "N2" , "N", 2, 0 },;
{ "N3" , "N", 2, 0 },;
{ "N4" , "N", 2, 0 },;
{ "N5" , "N", 2, 0 }}
the conversion from historical file.txt to aData array does it well in fact I can see it in a browse
- Code: Select all Expand view
- Local cFieldList:="data,ruota,n1,n2,n3,n4,n5"
Local csvfile := cDirZip+"storico.txt"
Local cSymbol := CHR( 9 )
Local cText := StrTran( MemoRead( csvfile ), CHR( 10 ), Chr(1) )
Local aData := HB_ATokens( cText, Chr(1), .t., .t. )
local nPos := 0
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
AEVAL( aData, { | arr, nIndex | aData[nIndex][1] := SUBSTR( arr[1], 9, 2 ) + "/" + SUBSTR( arr[1], 6, 2 ) + "/" + LEFT( arr[1], 4 ) } )
XBROWSER aData TITLE "TXT AS ARRAY" SETUP oBrw:cHeaders := { "Data", "Ruota", "Num1", "Num2", "Num3", "Num4", "Num5" }
when I then do the conversion, that is,
I copy the records of the aData array into the dbf archive, it makes errors, every now and then it does not insert the date field
- Code: Select all Expand view
local bprogress := { || (oProgress:Set( npos++ ),; //oProgress:SetPos( npos++ ),;
oSay[3]:SetText(ltrim(str(npos))),;
oSay[3]:refresh(),;
SysRefresh() ) }
nMeter := 0
oMeter:set(nMeter)
sysrefresh()
oProgress:ntotal:= len(aData)
olotto2:= TDatabase():Open( , cPath+"STORICO", "DBFCDX", .T. )
SET DELETED ON
olotto2:setorder(0)
oLotto2:gotop()
oLotto2:fw_ArrayToDBF( aData,,bProgress)
//FW_ArrayToDBF( aData, cFieldList, bProgress, lOverWrite, lRecallDeleted, bTrigger )
DbCloseAll()
return nil
result
Any solution pls ?