The format CSV converter in DBF or XLS
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
The format CSV converter in DBF or XLS
Whether there is in Alaska or eXpress ++ a function converting a CSV format in DBF or XLS (it is better in DBF)? If yes, that as it to use?
Re: The format CSV converter in DBF or XLS
hi,
you can use SDFDBE or DELIMITED to create a CSV.
you can use SDFDBE or DELIMITED to create a CSV.
greetings by OHR
Jimmy
Jimmy
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: The format CSV converter in DBF or XLS
And if it is already created (CSV), how it will load into DBF?
Re: The format CSV converter in DBF or XLS
Code: Select all
// This function loads a CSV file into a work area.
// The top line of the CSV file must contain the field names that match the work area.
FUNCTION DC_CSV2WorkArea( cCsvFileName )
LOCAL nHandle, cLine, aTokens, aFields, lStatus, cFieldName, aStru, ;
oRecord, cValue, i, nFound, nFieldType
nHandle := DC_TxtOpen( cCsvFileName )
IF nHandle <= 0
RETURN .f.
ENDIF
oRecord := DC_DbRecord():new()
cLine := DC_TxtLine( nHandle )
aFields := DC_TokenArray( cLine, ',' )
aStru := dbStruct()
DC_TxtSkip(nHandle,1)
DO WHILE !DC_TxtEof(nHandle)
cLine := DC_TxtLine(nHandle)
aTokens := DC_TokenArray(cLine,',')
dbGoTo(0)
DC_DbScatter(oRecord)
FOR i := 1 TO Len(aFields)
IF !Empty(cFieldName := Upper(Alltrim(aFields[i]))) .AND. Len(aTokens) == Len(aFields)
IF IsFieldVar(cFieldName)
nFound := AScan(aStru,{|a|Upper(Alltrim(a[1]))==cFieldName})
cValue := Alltrim(aTokens[i])
IF nFound > 0
nFieldType := aStru[nFound,2]
IF nFieldType $ 'CM'
oRecord:&(cFieldName) := cValue
ELSEIF nFieldType == 'N'
oRecord:&(cFieldName) := Val(cValue)
ELSEIF nFieldType == 'L'
oRecord:&(cFieldName) := ' ' + Upper(Alltrim(cValue)) + ' ' $ ' Y YES .T. TRUE T '
ELSEIF nFieldType == 'D'
oRecord:&(cFieldName) := CtoD(cValue)
ENDIF
ENDIF
ENDIF
ENDIF
NEXT
DC_DbGather(oRecord,.t.)
DC_TxtSkip(nHandle,1)
ENDDO
DC_TxtClose( nHandle )
RETURN .t.
The eXpress train is coming - and it has more cars.
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: The format CSV converter in DBF or XLS
I understand that I have a bad balance meanwhile that I receive at a forum and that I give on it: I receive much, and I give practically a zero. But nevertheless you couldn't provide the program which would address to the given function. I had a question: the database in which information from the CSV file will register, should be created to the appeal to this function? Whether if yes, that is possible to define automatically its structure and how it to make?