Strange error to converte a file
Posted: Mon Jan 04, 2021 8:57 am
If I compile a run the test it run ok
If insert the test on my application give me an error at this line
if cBuf[ -1 ] == 26 // check and remove Ctrl-Z
Function test()
local cFile:= cGetFile( "Timbrature (*.csv) | *.csv", "Selezionare un file", 1, )
local aData:={}
aData:= Csv_To_Data(cfile)
xbrowser adata
return nil
Function Csv_To_Data(cfile)
local cBuf, i,nFLines
local aTmp, aHeaders
// carico file csv
nFLines := FLineCount( cFile )
i := 1
cBuf := MemoRead( cFile )
cBuf := STRTRAN(cBuf,",",";")
cBuf := STRTRAN(cBuf,'"','')
// parse and make a multi dimentional array
if cBuf[ -1 ] == 26 // check and remove Ctrl-Z <--------------------
cBuf := Left( cBuf, Len( cBuf ) - 1 )
endif
if Right( cBuf, 2 ) != CRLF
// pad with CRLF if needed, not to miss the last line
cBuf += CRLF
endif
cBuf := StrTran( cBuf, CRLF, Chr( 10 ) )
aTmp := hb_aTokens( cBuf, Chr(10) )
AEval( aTmp, { |c,i| aTmp[ i ] := hb_aTokens( c, ';' ) } )
aHeaders := aTmp[ 1 ]
aTmp := ADel( aTmp, 1 )
aSize( aTmp, Len( aTmp ) - 1 )
return aTmp
the file csv
the error.log
Any solution pls ?
If insert the test on my application give me an error at this line
if cBuf[ -1 ] == 26 // check and remove Ctrl-Z
Function test()
local cFile:= cGetFile( "Timbrature (*.csv) | *.csv", "Selezionare un file", 1, )
local aData:={}
aData:= Csv_To_Data(cfile)
xbrowser adata
return nil
Function Csv_To_Data(cfile)
local cBuf, i,nFLines
local aTmp, aHeaders
// carico file csv
nFLines := FLineCount( cFile )
i := 1
cBuf := MemoRead( cFile )
cBuf := STRTRAN(cBuf,",",";")
cBuf := STRTRAN(cBuf,'"','')
// parse and make a multi dimentional array
if cBuf[ -1 ] == 26 // check and remove Ctrl-Z <--------------------
cBuf := Left( cBuf, Len( cBuf ) - 1 )
endif
if Right( cBuf, 2 ) != CRLF
// pad with CRLF if needed, not to miss the last line
cBuf += CRLF
endif
cBuf := StrTran( cBuf, CRLF, Chr( 10 ) )
aTmp := hb_aTokens( cBuf, Chr(10) )
AEval( aTmp, { |c,i| aTmp[ i ] := hb_aTokens( c, ';' ) } )
aHeaders := aTmp[ 1 ]
aTmp := ADel( aTmp, 1 )
aSize( aTmp, Len( aTmp ) - 1 )
return aTmp
the file csv
Code: Select all
"UserName","Activity","Work Date","Time Worked"
"Falconi Silvio","In","30-12-2020","08:07"
"Falconi Silvio","Out","30-12-2020","14:12"
"Falconi Silvio","In","29-12-2020","08:05"
"Falconi Silvio","Out","29-12-2020","14:22"
"Falconi Silvio","In","28-12-2020","08:02"
"Falconi Silvio","Out","28-12-2020","14:02"
"Falconi Silvio","In","23-12-2020","07:57"
"Falconi Silvio","Out","23-12-2020","14:01"
"Falconi Silvio","In","22-12-2020","08:04"
"Falconi Silvio","Out","22-12-2020","14:02"
"Falconi Silvio","In","21-12-2020","08:10"
"Falconi Silvio","Out","21-12-2020","14:00"
"Falconi Silvio","In","18-12-2020","08:10"
"Falconi Silvio","Out","18-12-2020","14:09"
"Falconi Silvio","In","17-12-2020","08:11"
"Falconi Silvio","Out","17-12-2020","14:03"
"Falconi Silvio","In","16-12-2020","08:01"
"Falconi Silvio","Out","16-12-2020","14:04"
"Falconi Silvio","In","15-12-2020","08:02"
"Falconi Silvio","Out","15-12-2020","14:05"
"Falconi Silvio","In","14-12-2020","07:56"
"Falconi Silvio","Out","14-12-2020","14:11"
"Falconi Silvio","In","12-12-2020","08:18"
"Falconi Silvio","Out","12-12-2020","14:05"
"Falconi Silvio","In","11-12-2020","07:58"
"Falconi Silvio","Out","11-12-2020","14:02"
"Falconi Silvio","In","10-12-2020","08:09"
"Falconi Silvio","Out","10-12-2020","14:10"
"Falconi Silvio","In","9-12-2020","08:15"
"Falconi Silvio","Out","9-12-2020","14:03"
"Falconi Silvio","In","7-12-2020","07:59"
"Falconi Silvio","Out","7-12-2020","14:03"
"Falconi Silvio","In","5-12-2020","08:07"
"Falconi Silvio","Out","5-12-2020","14:13"
"Falconi Silvio","In","4-12-2020","07:59"
"Falconi Silvio","Out","4-12-2020","14:04"
"Falconi Silvio","In","3-12-2020","07:56"
"Falconi Silvio","Out","3-12-2020","14:00"
"Falconi Silvio","In","2-12-2020","08:11"
"Falconi Silvio","Out","2-12-2020","14:00"
"Falconi Silvio","In","1-12-2020","07:59"
"Falconi Silvio","Out","1-12-2020","14:02"
the error.log
Code: Select all
Application
===========
Path and name: C:\Work\Prg\TimeCard\Timecard.Exe (32 bits)
Size: 7,936,512 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 20.12
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.1, Build 7600
Time from start: 0 hours 0 mins 12 secs
Error occurred at: 04-01-2021, 09:37:10
Error description: Error BASE/1068 Parametro errato: accesso all'array
Args:
[ 1] = C UserName;Activity;Work Date;Time Worked
Falconi Silvio;In;30-12-2020;08:07
Falconi Silvio;Out;30-12-2020;14:12
Falconi Silvio;In;29-12-2020;08:05
Falconi Silvio;Out;29-12-2020;14:22
Falconi Silvio;In;28-12-2020;08:02
Falconi Silvio;Out;28-12-2020;14:02
Falconi Silvio;In;23-12-2020;07:57
Falconi Silvio;Out;23-12-2020;14:01
Falconi Silvio;In;22-12-2020;08:04
Falconi Silvio;Out;22-12-2020;14:02
Falconi Silvio;In;21-12-2020;08:10
Falconi Silvio;Out;21-12-2020;14:00
Falconi Silvio;In;18-12-2020;08:10
Falconi Silvio;Out;18-12-2020;14:09
Falconi Silvio;In;17-12-2020;08:11
Falconi Silvio;Out;17-12-2020;14:03
Falconi Silvio;In;16-12-2020;08:01
Falconi Silvio;Out;16-12-2020;14:04
Falconi Silvio;In;15-12-2020;08:02
Falconi Silvio;Out;15-12-2020;14:05
Falconi Silvio;In;14-12-2020;07:56
Falconi Silvio;Out;14-12-2020;14:11
Falconi Silvio;In;12-12-2020;08:18
Falconi Silvio;Out;12-12-2020;14:05
Falconi Silvio;In;11-12-2020;07:58
Falconi Silvio;Out;11-12-2020;14:02
Falconi Silvio;In;10-12-2020;08:09
Falconi Silvio;Out;10-12-2020;14:10
Falconi Silvio;In;9-12-2020;08:15
Falconi Silvio;Out;9-12-2020;14:03
Falconi Silvio;In;7-12-2020;07:59
Falconi Silvio;Out;7-12-2020;14:03
Falconi Silvio;In;5-12-2020;08:07
Falconi Silvio;Out;5-12-2020;14:13
Falconi Silvio;In;4-12-2020;07:59
Falconi Silvio;Out;4-12-2020;14:04
Falconi Silvio;In;3-12-2020;07:56
Falconi Silvio;Out;3-12-2020;14:00
Falconi Silvio;In;2-12-2020;08:11
Falconi Silvio;Out;2-12-2020;14:00
Falconi Silvio;In;1-12-2020;07:59
Falconi Silvio;Out;1-12-2020;14:02
[ 2] = N -1
Stack Calls
===========
Called from: source\PWeb.prg => TIMEIMPORT( 82 )
Called from: source\PWeb.prg => (b)WEBCONVERSIONE( 39 )
Called from: .\source\classes\DIALOG.PRG => (b)TDIALOG( 97 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:DISPLAY( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 1127 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
Called from: source\PWeb.prg => WEBCONVERSIONE( 40 )
Called from: source\Main.prg => (b)TAPPLICATION_BUILDBTNBAR( 765 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 713 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 999 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1817 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2051 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1097 )
Called from: source\Main.prg => TAPPLICATION:ACTIVATE( 407 )
Called from: source\Main.prg => MAIN( 52 )
System
======
CPU type: Intel(R) Core(TM) i7 CPU Q 740 @ 1.73GHz 1850 Mhz
Hardware memory: 8117 megs
Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %
Windows total applications running: 5
1 ,
2 , C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189
3 , C:\Windows\syswow64\SHLWAPI.dll
4 , C:\Work\Prg\TimeCard\Timecard.Exe
5 GDI+ Window, C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225
Variables in use
================
Procedure Type Value
==========================
TIMEIMPORT
Param 1: O Class: ERROR
(b)WEBCONVERSIONE
Param 1: O Class: TPROGRESS
Param 2: O Class: TSAY
Param 3: C "C:\Users\silvio\Downloads\timbrature_2021-01-04.csv"
Local 1: C "UserName;Activity;Work Date;Time Worked
Falconi Silvio;In;30-12-2020;08:07
Falconi Silvio;Out;30-12-2020;14:12
Falconi Silvio;In;29-12-2020;08:05
Falconi Silvio;Out;29-12-2020;14:22
Falconi Silvio;In;28-12-2020;08:02
Falconi Silvio;Out;28-12-2020;14:02
Falconi Silvio;In;23-12-2020;07:57
Falconi Silvio;Out;23-12-2020;14:01
Falconi Silvio;In;22-12-2020;08:04
Falconi Silvio;Out;22-12-2020;14:02
Falconi Silvio;In;21-12-2020;08:10
Falconi Silvio;Out;21-12-2020;14:00
Falconi Silvio;In;18-12-2020;08:10
Falconi Silvio;Out;18-12-2020;14:09
Falconi Silvio;In;17-12-2020;08:11
Falconi Silvio;Out;17-12-2020;14:03
Falconi Silvio;In;16-12-2020;08:01
Falconi Silvio;Out;16-12-2020;14:04
Falconi Silvio;In;15-12-2020;08:02
Falconi Silvio;Out;15-12-2020;14:05
Falconi Silvio;In;14-12-2020;07:56
Falconi Silvio;Out;14-12-2020;14:11
Falconi Silvio;In;12-12-2020;08:18
Falconi Silvio;Out;12-12-2020;14:05
Falconi Silvio;In;11-12-2020;07:58
Falconi Silvio;Out;11-12-2020;14:02
Falconi Silvio;In;10-12-2020;08:09
Falconi Silvio;Out;10-12-2020;14:10
Falconi Silvio;In;9-12-2020;08:15
Falconi Silvio;Out;9-12-2020;14:03
Falconi Silvio;In;7-12-2020;07:59
Falconi Silvio;Out;7-12-2020;14:03
Falconi Silvio;In;5-12-2020;08:07
Falconi Silvio;Out;5-12-2020;14:13
Falconi Silvio;In;4-12-2020;07:59
Falconi Silvio;Out;4-12-2020;14:04
Falconi Silvio;In;3-12-2020;07:56
Falconi Silvio;Out;3-12-2020;14:00
Falconi Silvio;In;2-12-2020;08:11
Falconi Silvio;Out;2-12-2020;14:00
Falconi Silvio;In;1-12-2020;07:59
Falconi Silvio;Out;1-12-2020;14:02"
Local 2: N 1
Local 3: N 42
Local 4: U
Local 5: U
Local 6: A Len: 2
Local 7: U
Local 8: U
Local 9: U
Local 10: U
Local 11: U
Local 12: U
Local 13: U
Local 14: U
Local 15: U
Local 16: L .F.
Local 17: L .F.
Local 18: C "UserName;Activity;Work Date;Time Worked
Falconi Silvio;In;30-12-2020;08:07
Falconi Silvio;Out;30-12-2020;14:12
Falconi Silvio;In;29-12-2020;08:05
Falconi Silvio;Out;29-12-2020;14:22
Falconi Silvio;In;28-12-2020;08:02
Falconi Silvio;Out;28-12-2020;14:02
Falconi Silvio;In;23-12-2020;07:57
Falconi Silvio;Out;23-12-2020;14:01
Falconi Silvio;In;22-12-2020;08:04
Falconi Silvio;Out;22-12-2020;14:02
Falconi Silvio;In;21-12-2020;08:10
Falconi Silvio;Out;21-12-2020;14:00
Falconi Silvio;In;18-12-2020;08:10
Falconi Silvio;Out;18-12-2020;14:09
Falconi Silvio;In;17-12-2020;08:11
Falconi Silvio;Out;17-12-2020;14:03
Falconi Silvio;In;16-12-2020;08:01
Falconi Silvio;Out;16-12-2020;14:04
Falconi Silvio;In;15-12-2020;08:02
Falconi Silvio;Out;15-12-2020;14:05
Falconi Silvio;In;14-12-2020;07:56
Falconi Silvio;Out;14-12-2020;14:11
Falconi Silvio;In;12-12-2020;08:18
Falconi Silvio;Out;12-12-2020;14:05
Falconi Silvio;In;11-12-2020;07:58
Falconi Silvio;Out;11-12-2020;14:02
Falconi Silvio;In;10-12-2020;08:09
Falconi Silvio;Out;10-12-2020;14:10
Falconi Silvio;In;9-12-2020;08:15
Falconi Silvio;Out;9-12-2020;14:03
Falconi Silvio;In;7-12-2020;07:59
Falconi Silvio;Out;7-12-2020;14:03
Falconi Silvio;In;5-12-2020;08:07
Falconi Silvio;Out;5-12-2020;14:13
Falconi Silvio;In;4-12-2020;07:59
Falconi Silvio;Out;4-12-2020;14:04
Falconi Silvio;In;3-12-2020;07:56
Falconi Silvio;Out;3-12-2020;14:00
Falconi Silvio;In;2-12-2020;08:11
Falconi Silvio;Out;2-12-2020;14:00
Falconi Silvio;In;1-12-2020;07:59
Falconi Silvio;Out;1-12-2020;14:02"
Local 19: N -1
Local 20: U
Local 21: U
(b)TDIALOG
Param 1: U
TDIALOG:DISPLAY
Param 1: O Class: TDIALOG
TDIALOG:HANDLEEVENT
DIALOGBOXINDIRECT
Param 1: N 15
Param 2: N 0
Param 3: N 0
TDIALOG:ACTIVATE
Param 1: N 4194304
Param 2: C "€ È€ ñ e U n m o m e n t o p e r f a v o r e V m T B I T M A P P q n S T A T I C I m p o r t a n d o f i l e R e p o r t . . . P / Z o S T A T I C P 9 È p m s c t l s _ p r o g r e s s 3 2 "
Param 3: N 5506110
Param 4: O Class: TDIALOG
WEBCONVERSIONE
Param 1: U
Param 2: U
Param 3: U
Param 4: L .T.
Param 5: U
Param 6: L .T.
Param 7: U
Param 8: U
Param 9: U
Param 10: U
Param 11: U
Param 12: L .F.
Param 13: O Class: TDIALOG
Param 14: U
Local 1: N 5506110
Local 2: S
Local 3: O Class: TDIALOG
(b)TAPPLICATION_BUILDBTNBAR
Local 1: O Class: TDIALOG
Local 2: O Class: TBITMAP
Local 3: O Class: TSAY
Local 4: O Class: TPROGRESS
Local 5: C "C:\Users\silvio\Downloads\timbrature_2021-01-04.csv"
TBTNBMP:CLICK
Param 1: O Class: TBTNBMP
TBTNBMP:LBUTTONUP
TCONTROL:HANDLEEVENT
Param 1: N 32
Param 2: N 21
Param 3: N 0
Local 1: L .T.
Local 2: N 0
Local 3: S
TBTNBMP:HANDLEEVENT
Param 1: N 514
Param 2: N 0
Param 3: N 2097173
Local 1: U
_FWH
Param 1: N 514
Param 2: N 0
Param 3: N 2097173
WINRUN
Param 1: N 2097173
Param 2: N 514
Param 3: N 0
Param 4: N 2097173
Param 5: N 8
Local 1: O Class: TBTNBMP
TWINDOW:ACTIVATE
Param 1: N 5506110
TAPPLICATION:ACTIVATE
Param 1: C "NORMAL"
Param 2: U
Param 3: U
Param 4: U
Param 5: B {|| ... }
Param 6: B {|| ... }
Param 7: U
Param 8: B {|| ... }
Param 9: U
Param 10: U
Param 11: U
Param 12: U
Param 13: U
Param 14: U
Param 15: U
Param 16: U
Param 17: B {|| ... }
Param 18: U
Param 19: U
Param 20: L .F.
Local 1: O Class: TWINDOW
Local 2: U
Local 3: U
MAIN
Local 1: O Class: TAPPLICATION
Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFCDX
DBFNTX
DataBases in use
================
1: TI RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
1 0 .T. .T.
Indexes in use TagName
=> VAL(Codice) PRCODIGO
Relations in use
2: PR RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
1 4 .F. .F.
Indexes in use TagName
=> VAL(Codice) PRCODIGO
UPPER(Descri) PRDESC
Relations in use
3: => PE RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
3 3 .F. .F.
Indexes in use TagName
=> CODICE DPCODICE
NOMEINTERO DPNOME
Relations in use
Classes in use:
===============
1 ERROR
2 HBCLASS
3 HBOBJECT
4 TAPPLICATION
5 TFONT
6 TWINDOW
7 TCONTROL
8 TBITMAP
9 TIMAGE
10 TINI
11 TRECT
12 TGET
13 TMULTIGET
14 TCOMBOBOX
15 TICON
16 TBRUSH
17 TMENU
18 TREG32
19 TMENUITEM
20 TMSGBAR
21 TMSGITEM
22 TTIMER
23 TCURSOR
24 TBAR
25 TBTNBMP
26 TDIALOG
27 TSAY
28 TPROGRESS
29 TSTRUCT
Memory Analysis
===============
736 Static variables
Dynamic memory consume:
Actual Value: 1769472 bytes
Highest Value: 1769472 bytes