DBF to CSV - converter 3.1 ( Update )

glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 1.2 ( Update )

Post by glnklein »

würdest du mir den quellcode geben oder wenn lieber nicht dann ewentuell kürz hinzufügen ???

mir würde es schon reichen wenn da progam die ini datei einliest und dann nach den parametern umwandelt , danke

ps mein english ist VIEL zu schlecht
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 1.2 ( Update )

Post by ukoenig »

Ich werde eine < prg-create function > hinzufügen.
Das Resultat kann in das eigene Programm eingebunden werden
und enthält alle notwendigen Schritte.


I will add a < PRG-create > function.
The result will include all needed steps and can be added in another program.


Viele Grüße

best regards

Image

Image

Uwe :lol:
Last edited by ukoenig on Thu Jan 02, 2014 3:42 pm, edited 5 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 1.2 ( Update )

Post by glnklein »

DANKE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 1.2 ( Update )

Post by ukoenig »

Komplette Neuentwicklung.
Nun ist es möglich, alle Daten in einer INI-datei zu speichern
und mit einem Buttonclick eine CSV-Datei zu erzeugen ohne den Config-dialog zu öffnen.
Ein Index mit max. 3 Feldern kann definiert werden, für eine sortierte CSV-datei.
Selektierte Felder werden in einem 2. Array gespeichert.
Ebenfalls wird eine 2. DBF mit den selektierten Feldern erzeugt.
Eine PRG-datei kann Zwecks Einbindung in eigene Programme erzeugt werden.


CSV to DBF ist in Planung !!!

completely new development.
Now it is possible to save all settings to a INI-file.
A index with max 3 fields can be defined for a sorted CSV-file.
Once, everything is defined / selected inside the config-dialog,
a CSV-file can be created with only one button-click from the main-window.
( without opening the Config-dialog )
Selected fields are saved to a second array.
From this array a new DBF with _ + original name, is created as well together with the CSV-file.
A PRG-file can be created to include it in other programs.


CSV to DBF is under construction !!!

Image

Viele Grüße

best regards

Uwe :lol:
Last edited by ukoenig on Sat Jan 04, 2014 3:51 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 1.2 ( Update )

Post by glnklein »

ukoenig wrote:Komplette Neuentwicklung.
Nun ist es möglich, alle Daten in einer INI-datei zu speichern
und mit einem Buttonclick eine CSV-Datei zu erzeugen ohne den Config-dialog zu öffnen.
Ein Index mit max. 3 Feldern kann definiert werden, für eine sortierte CSV-datei.
Selektierte Felder werden in einem 2. Array gespeichert.
Ebenfalls wird eine 2. DBF mit den selektierten Feldern erzeugt.
Eine PRG-datei kann Zwecks Einbindung in eigene Programme erzeugt werden.


CSV to DBF ist in Planung !!!

completely new development.
Now it is possible to save all settings to a INI-file.
A index with max 3 fields can be defined for a sorted CSV-file.
Once, everything is defined / selected inside the config-dialog,
a CSV-file can be created with only one button-click from the main-window.
( without opening the Config-dialog )
Selected fields are saved to a second array.
From this array a new DBF with _ + original name, is created as well together with the CSV-file.
A PRG-file can be created to include it in other programs.



Uwe :lol:

tool !!!!!!
kann man es schon herunterladen und ein ausführen nur über cmd ist auch möglich oder meintest du das mit PRG-datei
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 1.2 ( Update )

Post by ukoenig »

Noch in der Testphase.
Weitere Funktionen hinzugefügt :
1. Resultat mit xBrowse öffnen.
2. CSV mit Button öffnen.
3. Beliebiger Index-mix : Character, Numeric and Logisch
4. Beliebiger Delimiter
5. Button für CSV-Zielverzeichnis hinzugefügt


Wird eine strukturierte CSV mit original Feldlängen benötigt ?

Still testing ...
Some more functions added :
1. open result with xBrowse.
2. CSV open on Button-action,
3. Possible to mix a Index with any field-types
4. owner defined delimiter
5. button for CSV-destination directory added


a structured CSV with original fieldlength needed ?

Image

Results :
sorted on MARRIED + LAST + SALARY ( logic + character + numeric )

xBrowse ( project-DBF ) :

Image

Angelwriter ( CSV ) :

Image

Viele Grüße

best regards

Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 1.2 ( Update )

Post by glnklein »

nein nicht umbedingt , das man es ohne maus also nur im cmd aufführen kann ist viel wichtiger :-))

darf ich fragen wie weit du bist ???
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 1.2 ( Update )

Post by ukoenig »

Still the MEMO-section I have to test ( some problems with multiline ), the rest works fine.
I added to convert from command-line.
What are the parameters You need ? ( all settings are loaded from INI )
Command-line : only the DBF-call ( loaded from subdirectory /data ) :
dbfcsv .\data\customer.dbf

Es sind noch Arbeiten an der MEMO-section durchzuführen ( einige Probleme mit Multiline ), der Rest funktioniert.
Die Commandline - Option ist neu.
Welche Parameter werden benötigt ? ( Einstellungen werden aus der INI gewählt )
Command-line : nur ein DBF-aufruf aus dem Unterverzeichnis /Data : dbfcsv .\data\customer.dbf


Image

Image

A result :
Optional with fieldinfo, to build a DBF from a CSV-file.
Still problems, to write MEMO-multilines :


Ein Resultat :
Optional mit Feldinfos, um eine DBF aus einer CSV zu erzeugen.
Noch Probleme mit MEMO-multiline.


Image

Code: Select all

STATIC Function DBF_TO_CSV( aFields_ )
LOCAL h, i, nFields, uData
LOCAL aFN_ := {}

BUILD_IDX() // build a defined index of the selected DBF

IF EMPTY(aFields_)
    nFields := len(aStruc[2])
    ASIZE(aFN_, nFields)
    FOR i := 1 to nFields
        aFN_[i] := i
    NEXT
ELSE
    nFields := len(aFields_)
    ASIZE(aFN_, nFields)
    FOR i := 1 to nFields
        aFN_[i] := (2)->( fieldpos(aFields_[i]) )
        IF aFN_[i] = 0 
            MsgAlert(  "Invalid field name: " + aFields_[i], "Error" )
            DBSELECTAREA( 2 )
            NET_CLOSE( 3, 3, .T.)
            DELETE FILE &cTMP
            aStruc[2] := {}
            AADD(aStruc[2], { "FIELD1", "C", 1, 0 }) 
            cTMP := cFilepath( cDBF ) + "_" + cFileNoExt( cDBF ) + ".dbf"
            DBCREATE( cTMP, aStruc[2] )
            RETURN(NIL)
        ENDIF      
    NEXT
ENDIF

h := FCREATE(cCSV, FC_NORMAL)
IF h = F_ERROR 
//  MsgAlert( "Failed to create CSV file " + cCSV + ": " + cFerror(), "Error" )
    RETURN(NIL)
ENDIF

MsgRun( "Working...", "CSV-Convert", { |oDlg1| DBF_CSV( aFN_, nFields, h ) } )

IF cShow = "Writer"
    IF FILE( cCSV )
        WAITRUN( c_path + "Angelwriter.exe" + " " + cCSV )
    ELSE
        MsgAlert( "Cannot load :" + CRLF + cCSV, "Missing CSV-file" )
    ENDIF
ENDIF

RETURN(NIL)

// --------------------------

FUNCTION DBF_CSV( aFN_, nFields, h )
LOCAL cText, nLines := 0, nRecords := 0, I, F   

// MsgAlert( cDELIM, "Delimiter" )
// DBF_TO_CSV( cRDD, cDELIM, cDateFmt, cEOL, cHeader, cMemos, cLOGIC, aFields_ )

IF cHeader = "Yes"
    //#define DBS_NAME        1
    //#define DBS_TYPE        2
    //#define DBS_LEN         3
    //#define DBS_DEC         4
    cText := ""
    FOR i := 1 to nFields
        f := aFN_[I]
        IF cFieldsize = "Yes"
            cText += aStruc[2][F, DBS_NAME] + "-" + aStruc[2][F, DBS_TYPE] + ;
                                                "-" + ALLTRIM(STR(aStruc[2][F, DBS_LEN])) + ;
                                                "-" + ALLTRIM(STR(aStruc[2][F, DBS_DEC]))
        ELSE
            cText += aStruc[2][F, DBS_NAME] 
        ENDIF
        IF i < nFields
            cText += cDELIM // ","
        ENDIF
    NEXT
    FWRITE(h, cText + CRLF)
    nLines++
ENDIF

(2)->( DBGoTop() )
DO WHILE !(2)->( EOF() ) 
    IF INKEY() == K_ESC
        EXIT
    ENDIF
    FOR I := 1 to nFields
        F := aFN_[I]
        cText := ""
        uData := (2)->( FIELDGET(f) )
        DO CASE
            CASE aStruc[2][F, DBS_TYPE] == "C"
                IF cFTrim == "Yes"
                    cText := RTRIM(uData) // Enquote(RTRIM(uData))
                ELSE
                    cText := uData // Enquote(uData) 
                ENDIF
            CASE aStruc[2][F, DBS_TYPE] == "D"
                IF !EMPTY(uData)
                    cText := DTOC(uData)
                ENDIF
            CASE aStruc[2][F, DBS_TYPE] == "L"
                IF cLOGIC = "TRUE"
                    cText := IIF(uData, "TRUE", "FALSE")
                ELSEIF cLOGIC = "T"
                    cText := IIF(uData, "T", "F")
                ELSEIF cLOGIC = ".T."
                    cText := IIF(uData, ".T.", ".F.")
                ENDIF
            CASE aStruc[2][F, DBS_TYPE] == "M"
                IF cMemos = "Yes" .and. !EMPTY(uData)
                    ADDMEMO(uData, h, @cText, @nLines)
                ENDIF
            CASE aStruc[2][F, DBS_TYPE] == "N"
                IF cFTrim == "Yes"
                    cText := LTRIM(str(uData, aStruc[2][F, DBS_LEN], aStruc[2][F, DBS_DEC]))
                ELSE
                    cText := STR(uData, aStruc[2][f, DBS_LEN], aStruc[2][F, DBS_DEC] )
                ENDIF
        END CASE
        IF I < nFields
            FWRITE(h, cText + cDELIM ) // ",")
        ELSEIF !EMPTY(cText)
            FWRITE(h, cText)
        ENDIF
    NEXT
    FWRITE(h, CRLF)
    nLines++
    nRecords++
    (2)->( DBSkip() )
ENDDO

FCLOSE(h)

IF LASTKEY() == K_ESC
    MsgAlert( "Cancelled.  Output file is incomplete.", "Attention" )
ELSE
    MsgAlert(  LTRIM(STR(nLines)) + " lines written for " + LTRIM(STR(nRecords)) + " records." + CRLF + ;
    "Using Delimiter : < " + cDELIM + " >", "Attention" )
ENDIF

RETURN(NIL)

// -------------------------

STATIC FUNCTION ADDMEMO( cMemo, h, cText, nLines )
LOCAL I, ILEN, A, Q, C
LOCAL cQUOTE := '"'
//LOCAL CRLF := chr(13) + chr(10)
LOCAL lMULTILINE := cEOL == ""  

// MEMO-single Line  Yes   cEOL := "\###", No   cEOL := "" Multiline 

cText += cQUOTE
      
Q := ASC(cQUOTE)
ILEN := LEN(cMemo)

//IF (2)->(ORDKEYNO()) < 2
//  MsgAlert( ILEN, "Record : " + ALLTRIM(STR( (2)->(ORDKEYNO() ) )) )
//ENDIF

I := 1
DO WHILE I <= ILEN 
    C := SUBSTR(cMemo, I, 1) // 1. Character
    A := ASC(C)
    // MsgAlert( A, "1. ASC :" + C )
    IF A == Q
        cText += cQUOTE + cQUOTE // Double literal quotes
    ELSEIF A == 13 .or. A == 10
        IF lMULTILINE // cEOL == "" 
            FWRITE(h, cText + CRLF)
            nLines++
            cText := ''
        ELSE
            cText += cEOL
        ENDIF
        IF A == 13 .and. I < ILEN // CRLF?
            IF ASC(SUBSTR(cMemo, I + 1, 1)) == 13 .or. ASC(SUBSTR(cMemo, I + 1, 1))  == 10
                I++
            endif
        ENDIF
    ELSEIF A == 141
        // Replace soft line breaks with a space if not already adjacent to one
        IF I > 1 .and. substr(cMemo, I - 1, 1) <> " "
            cText += " "
        ENDIF
    ELSE
        cText+= C  
    ENDIF
    I++
ENDDO

cText += cQuote

RETURN(NIL)
 
best regards

viele Grüße

Uwe :?:
Last edited by ukoenig on Mon Jan 13, 2014 4:25 pm, edited 6 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 1.2 ( Update )

Post by glnklein »

ich habe leider keine ahnung von dieser programiersprache deshalb kann ich da nicht helfen , ich benötige
in der cmd box nur per aufruf : datenbank einlesen und in eine csv umwandel und speichern --fertig

danke für die arbeit
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 1.2 ( Update )

Post by ukoenig »

< Only a DBF-call is needed. >

OK, that works.

OK, das funktioniert.

best regards

Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 1.2 ( Update )

Post by glnklein »

weist du schon wan es eine vorab version geben wird da ich es für die arbeit brauche ???
danke
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 1.2 ( Update )

Post by ukoenig »

I think, I can add a downloadlink this weekend for testing.
I still have to add the REVERSE-option CSV > DBF, to create a DBF from a CSV-file
MEMOS are working fine now ( again more options added ).


Ich glaube, Ich kann eine Vorabversion dieses Wochenende für Tests fertigstellen.
Der zweite Teil REVERSE-option CSV > DBF ist noch hinzuzufügen, um eine DBF aus CSV zu erzeugen.
MEMOS funktionieren nun ( weitere Optionen sind hinzugefügt worden )


Maybe I need some help, how to create a DBF from the CSV-headline ? ( needed for the second toolpart )
LAST-C-20-0;HIREDATE-D-8-0;MARRIED-L-1-0;AGE-N-2-0;NOTES1-C-70-0;NOTES2-M-10-0;EMPTY1-C-10-0

Image

Image

Image

The working PRG and EXE ( uses the convert-functions of the tool )

You can define fixed values ( not using the INI )

cDBF := "C:\Test\customer.dbf"
cCSV := "C:\Test\customer.csv"
cRDD := "DBFCDX"
cEOL := "\###"
cDateFmt := "yy-mm-dd"
cHeader := "Yes"
cMemos := "Yes"
cMemoline := "No"
cShow := "Yes"
cDELIM := ";"
cLOGIC := "TRUE"
cSort := "No"
cDescend := "No"
cFTrim := "Yes"
cFieldsize := "No"


// GET_INI() // overwrites the values from INI-file

The result of the created PRG + EXE

Image

Best regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: DBF to CSV - converter 3.1 ( Update )

Post by ukoenig »

The new update 3.1 => DOWNLOAD ( 5.2 MB ) :

http://www.pflegeplus.com/fw_downloads/DbfCsv3.zip

Image

The tool can create a EXE Mycsv.exe ( compiled exe is included )
there is a batchfile < commandline.bat > to test it from commandline.
< MYCSV.prg > works as standalone or can be included inside Your application.
The testfiles ( customer.dbf / fpt / csv ) are included in subdirectory \DATA


Das Tool kann Mycsv.exe erzeugen.
Mit der Batchdatei < commandline.bat > kann die Kommandline-funktionalität getested werden.
Die Testdateien ( Customer.dbf / fpt / csv ) sind im Unterverzeichnis \DATA gespeichert.


Best regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
glnklein
Posts: 8
Joined: Thu Jan 02, 2014 9:42 am

Re: DBF to CSV - converter 3.1 ( Update )

Post by glnklein »

big thanks
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: DBF to CSV - converter 3.1 ( Update )

Post by cnavarro »

Uwe, thanks
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Post Reply