Cvs files date field missing
Posted on 2016-10-13
I want to collect the dates of each filename. I am getting all the data of each filename except the dates. The date comes from the filenames like the building number. The building in the filenames are being stored with the other data except the dates. The filenames, for example, looks like this 100_2016-10-03_20-31. The first three numbers are the building numbers, then the date, and the _10-31 is the time. How can I get the dates stored as well? I have received an error message with this code that is in the program. FOR lnI = 1 TO m.LnCnt
LcDateStr= Chrtran (StrExact(laFiles. [m.lnI,1],'_','_')
The error message was File 'strexact.prg' does not exist.
LdFileDate = Date (Val (m.lcDateStr),Val(Substr (m.lcDateStr,6)),Val (Substr (m.lcDateStr,AT ('-',m.lcDateStr,2)+1)))
DO ImportFile WITH m.lcPath, laFiles [m.lnI,1], m.ldFileDate
The error message was Function argument value, type, or count is invalid.
OR IF I use the code below, I get an error message saying, " File 'strexact.prg' does not exist", and Function name is missing.
This is the code that is being used.
&&& CVS START
Create cursor mycursor (;
Building N (3,0), ;
Item no i,;
Quantity I , ;
Description c (21),;
* ---- Load cursor with CSV data.
Set order to building ascending
Lcpath = "H:\\Obra\Ldy\"
LnCnt = ADIR (laFiles, m.lcPath + m.lcFileMask)
Set century on
Set date American
LOCAL lcFileName, ldFileDate, LcDateStr
FOR lnI = 1 TO m.LnCnt
LcDateStr = Chrtran (StrExact (laFiles[m.lnI,1],'_','_')
DO ImportFile WITH m.lcPath, laFiles [m.lnI,1], Date (&lcDateStr)
Procedure Import File
LPARAMETERS lcPath, lcFileName, lcDate, lcFileMask
LOCAL lcLine, lnFH, lnBuilding, date, lcDateStr, FileName,
LnFH = FOPEN (m.lcPath +m.lcFileName)
IF m.lnFH > 0
LnBuilding = VAL (m.lcFileName)
FOR lnI= 1TO 3
lcLine = FGETS (m.lnFH, 1000)
DO WHILE !FEOF (m.lnFH)
LcLine = FGETS (m.lnFH, 1000)
LnA = VAL (LEFT (m.lcLine, AT (',', m.lcLine)-1))
LcLine = Substr (m.lcLine, AT (',', m.lcLine)+1)
LnB= VAL (LEFT (m.lcLine, AT (',', m.lcLine)-1))
LcLine = SUBSTR (m.lcLine, AT (',', m.lcLine)+1
LcC= ALLTRIM (SUBSTR (m.lcLine, AT ('"', m.lcLine)+1))
LcC= LEFT(m.lcC, LEN (m.lcC)-1)
INSERT INTO MyCursor (building, date, itemno, quantity, description) VALUES (m.lnBuilding, lcDateStr, m.lnA, m.lnB, m.lcC)
= FCLOSE (m.lnFH)