Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date problem with APPEND FROM csv file
Message
From
09/09/2016 08:22:07
 
 
To
08/09/2016 18:58:01
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01640585
Message ID:
01640643
Views:
149
Likes (1)
>>
>>Anyhow, I can verify that I see the exact same results as you. I know that's no consolation.
>>
>>Maybe you can try using GridExtras (http://www.sweetpotatosoftware.com/spsblog/PermaLink,guid,d6d71562-1655-4518-9341-527932970583.aspx). This is what I use for all importing and exporting of data from Excel, it may be able to handle CSV too.
>
>Yes, I was able to get similar results with the program code as given (dates aren't interpreted properly) -- but this is not surprising since in my environment is SET DATE AMERICAN
>
>However, if in the given code, I insert the following lines at the top:
>
SET DATE BRITISH
>SET CENTURY ON
>
>it starts working correctly.
>
>Original code:
>
CREATE CURSOR MyCursor (perfil C(1), act_med C(7), anno N(4), autog C(15), caso C(2), cas_ref C(3), codcen C(4), cod_egre C(1), complica N(2);
>	, diag C(7), diag2 C(7), diag3 C(7), diagegre2 C(7), diagegre3 C(7), dias N(3), dias_esta N(5), edad N(3), fecha D, fec_egre D;
>	, fec_nac D, gdx C(3), gere C(3), historia C(7), horae C(8), horai C(8), id C(6), mes N(2), meses N(3), nive C(2), nombre C(40);
>	, pac_e C(1), pac_s C(1), prioridad C(1), refere C(1), referido C(3), semana N(2), servi C(3), servirgh C(3), sexo C(1), tipat C(1);
>	, tipo_ase C(2), topico C(20), ubigeo C(6), svei N(1), idmes C(2), sele N(1), epidem N(1))
>
>APPEND FROM "MyCSV.csv" TYPE CSV   && CSV is attached.
>GO TOP
>BROWSE NOMODIFY && To see data.
>
>Modified code:
>
SET DATE BRITISH
>SET CENTURY ON
>CREATE CURSOR MyCursor (perfil C(1), act_med C(7), anno N(4), autog C(15), caso C(2), cas_ref C(3), codcen C(4), cod_egre C(1), complica N(2);
>	, diag C(7), diag2 C(7), diag3 C(7), diagegre2 C(7), diagegre3 C(7), dias N(3), dias_esta N(5), edad N(3), fecha D, fec_egre D;
>	, fec_nac D, gdx C(3), gere C(3), historia C(7), horae C(8), horai C(8), id C(6), mes N(2), meses N(3), nive C(2), nombre C(40);
>	, pac_e C(1), pac_s C(1), prioridad C(1), refere C(1), referido C(3), semana N(2), servi C(3), servirgh C(3), sexo C(1), tipat C(1);
>	, tipo_ase C(2), topico C(20), ubigeo C(6), svei N(1), idmes C(2), sele N(1), epidem N(1))
>
>APPEND FROM "MyCSV.csv" TYPE CSV   && CSV is attached.
>GO TOP
>BROWSE NOMODIFY && To see data.
>
>IMPORTANT: Even if you were careful to put SET DATE BRITISH in the main program file, if the code in question executes in a private data session -- the default configuration of SET DATE AMERICAN will be in effect (unless of course you set it explicitly in code). (i.e. in private data session, the system defaults apply)
>
>Another point: Another point to be careful about is if you have date or datetime constants in your code, make sure you specify them in the explicit format of {^yyyy.mm.dd} (or use the DATE() function) rather than a region-dependent format. Where this could bite you is the interpretation of that the interpretation of such constant in code is dependent on the region configuration at the time the code is compiled. Expressions such as CTOD("01/02/03") would give different results at runtime, depending on the date format set at the time that line of code is executed.
>
dDate = {01/02/03}   && dependent on SET DATE configuration at compile time
>dDate = CTOD("01/02/03")  && Dependent on SET DATE at run time
>dDate = {^2000.01.02}  && not dependent on SET DATE at runtime nor compile time
>dDate = DATE(2011,01,03)  && not dependent on SET DATE at runtime nor compile time
Hi Naoto,

the SET DATE BRITISH and SET CENTURY ON lines are in Luis' code. It is all running in the default datasession.

If you got it to work, that means you have some setting different to Luis and me.

This is my exact code:
SET DATE BRITISH
SET CENTURY ON ROLLOVER 50

CREATE CURSOR MyCursor (fecha D, fec_egre D;
, fec_nac D, gdx C(3), gere C(3), historia C(7), horae C(8), horai C(8), id C(6), mes N(2), meses N(3), nive C(2), nombre C(40);
, pac_e C(1), pac_s C(1), prioridad C(1), refere C(1), referido C(3), semana N(2), servi C(3), servirgh C(3), sexo C(1), tipat C(1);
, tipo_ase C(2), topico C(20), ubigeo C(6), svei N(1), idmes C(2), sele N(1), epidem N(1))

TEXT TO m.csv NOSHOW TEXTMERGE
fecha,fec_egre,fec_nac,gdx,gere,historia,horae,horai,id,mes,meses,nive,nombre,pac_e,pac_s,prioridad,refere,referido,semana,servi,servirgh,sexo,tipat,tipo_ase,topico,ubigeo,svei,idmes,sele,epidem
30/07/2016,01/01/2000,11/08/2015, ,26,6292, , , ,9,0, ,VALLE TORRES LAIA,C,C, , , ,30, ,AB1,F, ,1, ,0,1,GG,0,1
30/07/2016,01/01/2000,19/06/2011, ,26,5246, , , ,9,0, ,MAMANI APAZA JAIR,C,C, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
30/07/2016,01/01/2000,02/04/1973, ,26,5462, , , ,9,0, ,QUISPE TTITO FRANCISCO,C,C, , , ,30, ,AB1,M, ,75, ,0,1,GG,0,1
30/07/2016,01/01/2000,04/05/1938, ,26,553, , , ,9,0, ,SALAS MAMANI PAULINO,C,C, , , ,30, ,AB1,M, ,7, ,0,1,GG,0,1
30/07/2016,01/01/2000,12/04/1977, ,26,6554, , , ,9,0, ,CUELLAR FERNANDEZ FABIAN,C,C, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
30/07/2016,01/01/2000,07/01/1959, ,26,598, , , ,9,0, ,PASTOR PALOMINO JULIA,C,C, , , ,30, ,AB1,F, ,7, ,0,1,GG,0,1
30/07/2016,01/01/2000,22/05/2004, ,26,5291, , , ,9,0, ,FRISANCHO PIÑA NADIUSKA,N,N, , , ,30, ,AB1,F, ,1, ,0,1,GG,0,1
30/07/2016,01/01/2000,24/03/2015, ,26,6344, , , ,9,0, ,FRISANCHO PIÑA AARON,N,N, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
30/07/2016,01/01/2000,16/05/1968, ,26,6501, , , ,9,0, ,ROMAN QUISPE DE PORTILLO JUANA,C,C, , , ,30, ,AB1,F, ,7, ,0,1,GG,0,1
30/07/2016,01/01/2000,15/12/2010, ,26,6379, , , ,9,0, ,DEL AGUILA PASHANASTE LLEN,C,C, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
ENDTEXT

STRTOFILE(m.csv, "MyCsv.csv", 0)

APPEND FROM "MyCSV.csv" TYPE CSV && CSV is attached.
GO TOP
BROWSE NOMODIFY && To see data.
Let's see if we can work it out. - open the debugger window (make sure the Debug Output window is open)
- Go to Tools | Options
- Press and hold Shift and click OK

That will list off all your settings and you can copy and paste them here. Here are mine:

SET TALK OFF
SET NOTIFY ON
SET CLOCK STATUS
&& RecentlyUsedFiles = 9
&& DisplayCount = 15
SET COMPATIBLE OFF
SET PALETTE ON
SET BELL ON
SET BELL TO '', 1
SET SAFETY OFF
SET ESCAPE ON
SET LOGERRORS ON
SET KEYCOMP TO WINDOWS
SET CARRY OFF
SET CONFIRM OFF
SET BROWSEIMECONTROL OFF
SET STRICTDATE TO 2
&& TabOrdering = 0
&& ResWidth = 1024
&& ResHeight = 768
&& GridHorz = 6
&& GridVert = 6
&& ScaleUnits = 0
&& FormSetLib =
&& FormSetClass =
&& FormsLib =
&& FormsClass =
SET EXACT OFF
SET NEAR OFF
SET ANSI OFF
SET LOCK OFF
SET EXCLUSIVE OFF
SET MULTILOCKS ON
SET HEADINGS ON
SET DELETED ON
SET OPTIMIZE ON
SET UNIQUE OFF
SET CPDIALOG ON
SET REFRESH TO 0,5.000
SET ODOMETER TO 100
SET BLOCKSIZE TO 64
SET REPROCESS TO 0
SET COLLATE TO ""
&& SCCProvider = Microsoft Visual SourceSafe
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\SCCTEXT.PRG" TO _SCCTEXT
&& ProjectHookLib =
&& ProjectHookClass =
&& CrsBuffering = 1
&& CrsMethodUsed = 1
&& CrsWhereClause = 3
&& CrsFetchSize = 100
&& CrsMaxRows = -1
&& CrsNumBatch = 1
&& CrsUseMemoSize = 255
&& SQLDispLogin = 1
&& SQLTransactions = 1
&& SQLConnectTimeOut = 15
&& SQLIdleTimeOut = 0
&& SQLQueryTimeOut = 0
&& SQLWaitTime = 100
SET DEFAULT TO d:\temp
&& TMPFILES = c:\users\frank\appdata\local\temp
SET PATH TO DATA; LIBS; FORMS; MENUS; PROGRAMS; REPORTS; GRAPHICS; OTHER; TESTS;\development\vfp9\VMP2005\xlib; C:\PROGRAM FILES (x86)\Microsoft Visual FoxPro 9; ..\SSLib; ..\SSL_INT; ..\Graphics\XP; ..\..\StoneField\SFCommon; ..\..\Common; ..\..\Common\Thor; ..\..\Common\PEMEditor6; ..\..\Common\classes; ..\..\Common\forms; ..\..\Common\graphics; ..\..\Common\menus; ..\..\Common\others; ..\..\Common\progs; ..\..\Common\reports; \development\vfp9\StoneField\SFQuery; \development\vfp9\STONEFIELD\SDT\SDT.APP; \development\vfp9\StoneField\SDT\Source;C:\Program Files (x86)\Microsoft Visual FoxPro 9\FFC;\Development\VFP9\FoxUnit;vfpskin;\Development\VFP9\Common\FoxCharts_1.20\Source
&& HelpTo = d:\development\vfp9\dv_foxhelp.chm
&& HelpCollection =
SET HELP ON
SET HELP COLLECTION
SET HELP TO "d:\development\vfp9\dv_foxhelp.chm"
&& ResourceTo = c:\documents and settings\frank\application data\microsoft\visual foxpro 9\foxuser.dbf
SET RESOURCE ON
SET RESOURCE TO "c:\documents and settings\frank\application data\microsoft\visual foxpro 9\foxuser.dbf"
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\WIZARD.APP" TO _WIZARD
STORE "..\XLIB\XXBUILDER.PRG" TO _BUILDER
STORE "" TO _MENUDESIGNER
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\CONVERT.APP" TO _CONVERTER
STORE "D:\DEVELOPMENT\VFP9\VMP2005\XLIB\GENMENUX.PRG" TO _GENMENU
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\BROWSER.APP" TO _BROWSER
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\GALLERY.APP" TO _GALLERY
STORE "" TO _INCLUDE
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\BEAUTIFY.APP" TO _BEAUTIFY
STORE "" TO _GETEXPR
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\GENHTML.PRG" TO _GENHTML
STORE "D:\DEVELOPMENT\VFP9\VFPSTART.PRG" TO _STARTUP
STORE "C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\SAMPLES\" TO _SAMPLES
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\COVERAGE.APP" TO _COVERAGE
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\TASKLIST.APP" TO _TASKLIST
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\OBJECTBROWSER.APP" TO _OBJECTBROWSER
STORE "C:\DOCUMENTS AND SETTINGS\FRANK\APPLICATION DATA\MICROSOFT\VISUAL FOXPRO 9\FOXCODE.DBF" TO _FOXCODE
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\FOXCODE.APP" TO _CODESENSE
STORE "C:\DOCUMENTS AND SETTINGS\FRANK\APPLICATION DATA\MICROSOFT\VISUAL FOXPRO 9\FOXTASK.DBF" TO _FOXTASK
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\VFPXTAB.PRG" TO _GENXTAB
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\FOXREF.APP" TO _FOXREF
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\TOOLBOX.APP" TO _TOOLBOX
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\TASKPANE.APP" TO _TASKPANE
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\REPORTBUILDER.APP" TO _REPORTBUILDER
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\REPORTPREVIEW.APP" TO _REPORTPREVIEW
STORE "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL FOXPRO 9\REPORTOUTPUT.APP" TO _REPORTOUTPUT
SET SYSFORMATS OFF
SET SECONDS ON
SET CENTURY ON
&& CurrSymbol = $
SET CURRENCY LEFT
SET CURRENCY TO "$"
SET HOURS TO 12
SET DATE TO BRITISH
SET DECIMALS TO 2
SET FDOW TO 1
SET FWEEK TO 1
SET MARK TO ""
SET SEPARATOR TO ","
SET POINT TO "."
&& DebugEnvironment = 0
SET TRBETWEEN OFF
STORE 0.00 TO _THROTTLE
&& DebugOutputFileName =
&& TraceFontName = Courier New, 10, N, 1
&& WatchFontName = MS Sans Serif, 8, N, 1
&& LocalsFontName = MS Sans Serif, 8, N, 1
&& OutputFontName = MS Sans Serif, 8, N, 1
&& CallstackFontName = MS Sans Serif, 8, N, 1
&& TraceNormalColor = RGB(0,0,0,255,255,255), Auto, Auto
&& TraceExecutingColor = RGB(255,255,0,0,0,0), NoAuto, Auto
&& TraceCallstackColor = RGB(0,0,0,240,240,240), Auto, Auto
&& TraceBreakpointColor = RGB(255,0,0,0,0,0), NoAuto, Auto
&& TraceSelectedColor = RGB(255,255,255,0,0,0), Auto, Auto
&& WatchNormalColor = RGB(0,0,0,255,255,255), Auto, Auto
&& WatchSelectedColor = RGB(255,255,255,0,0,0), Auto, Auto
&& WatchChangedColor = RGB(255,0,0,255,255,255), NoAuto, Auto
&& LocalsNormalColor = RGB(0,0,0,255,255,255), Auto, Auto
&& LocalsSelectedColor = RGB(255,255,255,0,0,0), Auto, Auto
&& OutputNormalColor = RGB(0,0,0,255,255,255), Auto, Auto
&& OutputSelectedColor = RGB(255,255,255,0,0,0), Auto, Auto
&& CallstackNormalColor = RGB(0,0,0,255,255,255), Auto, Auto
&& CallstackSelectedColor = RGB(255,255,255,0,0,0), Auto, Auto
&& BookmarkColor = RGB(0,255,255,0,0,0), NoAuto, Auto
&& ShortcutColor = RGB(0,0,255,0,0,0), NoAuto, Auto
&& EditorCommentString = *!*
&& BackgroundCompile = 2
&& ParensHighlightDuration = 1500
&& RptGridHorz = 6
&& RptGridVert = 6
&& RptScaleUnits = 255
&& RptExprBuilderAlias = 0
&& RptBehavior = 90
&& RptFont = Tahoma, 10, N, 1
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform