Author | Topic: DbExport() ??!! | |
---|---|---|
Alain R | DbExport() ??!! on Mon, 07 Nov 2016 11:55:24 +0100 Hello eveybody I would like convert a dbf to a file txt The structure of txt must be : "4005086141896";"14189";"CHIMPANZE MALE";"1";"5.50"; "4005086144064";"14406";"SOURIS BLANCHE";"4";"3.99"; "4005086144071";"14407";"GRENOUILLE";"7";"4.50"; The description of DBF select b fichnom := drive + ":\bdce\fela.dbf" aStructure := { { "EAN" , "C", 13, 0 }, ; { "REFERENCE" , "C", 20, 0 }, ; { "LIBELLE" , "C", 50, 0 }, ; { "QUANTITE" , "C", 4, 0 }, ; { "PRIXTTC" , "C", 6, 0 } } DbCreate( FICHNOM, aStructure ) I use this command : reseau(drive + ":\bdce\fela",.t.,0) cFileCsv := drive + ":\bdce\stock_csv\ExtractArt_" + constr_date + ".csv" *********** Be careful I have put this command DbeInfo in pgm dbesys.prg *********** DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TOKEN,";" ) DbExport(cFileCsv,; {"EAN","Reference","libelle","quantite","prixttc"},; ,,,,,"DELCDX") The result of the runing in the txt is that : "4005086141896";"14189";"CHIMPANZE MALE";"1";"5.50" "4005086144064";"14406";"SOURIS BLANCHE";"4";"3.99" "4005086144071";"14407";"GRENOUILLE";"7";"4.50" Missing the end character ";" Have some idea ? Thanks a lot | |
Thomas Braun | Re: DbExport() ??!! on Mon, 07 Nov 2016 14:36:55 +0100 Alain R wrote: > Hello eveybody > > I would like convert a dbf to a file txt > > The structure of txt must be : > > "4005086141896";"14189";"CHIMPANZE MALE";"1";"5.50"; > "4005086144064";"14406";"SOURIS BLANCHE";"4";"3.99"; > "4005086144071";"14407";"GRENOUILLE";"7";"4.50"; > [...] > The result of the runing in the txt is that : > > "4005086141896";"14189";"CHIMPANZE MALE";"1";"5.50" > "4005086144064";"14406";"SOURIS BLANCHE";"4";"3.99" > "4005086144071";"14407";"GRENOUILLE";"7";"4.50" Well - field separators separate fields from each other (obviously and since there is no field after the last one, there is no need for an additional separator. > Have some idea ? Have you tried this one? DbeInfo(COMPONENT_DATA, DELDBE_RECORD_TOKEN,";"+ CHR(13)+CHR(10) ) HTH Thomas | |
James Loughner | Re: DbExport() ??!! on Mon, 07 Nov 2016 21:28:17 -0500 An extra ; at end is not at all standard format but if you must I'd do something like this assuming the dbf is opens and current #include Fileio.ch" Out := fopen("outfilename",FO_Write) IF Out > 0 GOTOP() DO WHILE !EOF() I := 1 Line := "" DO FIELDGET(I) != NIL Line := Line+FIELDGET(I)+";" ++I ENDDO fwrite(Out,Line) DBSkip() ENDDO fclose(Out) ELSE MSGBOX("Error out file could not be opened"."ERROR") ENDIF That should work with any DBF Jim On 11/07/2016 05:55 AM, Alain R wrote: > > Hello eveybody > > I would like convert a dbf to a file txt > > The structure of txt must be : > > "4005086141896";"14189";"CHIMPANZE MALE";"1";"5.50"; > "4005086144064";"14406";"SOURIS BLANCHE";"4";"3.99"; > "4005086144071";"14407";"GRENOUILLE";"7";"4.50"; > > The description of DBF > select b > fichnom := drive + ":\bdce\fela.dbf" > aStructure := { { "EAN" , "C", 13, 0 }, ; > { "REFERENCE" , "C", 20, 0 }, ; > { "LIBELLE" , "C", 50, 0 }, ; > { "QUANTITE" , "C", 4, 0 }, ; > { "PRIXTTC" , "C", 6, 0 } } > > DbCreate( FICHNOM, aStructure ) > > I use this command : > reseau(drive + ":\bdce\fela",.t.,0) > cFileCsv := drive + ":\bdce\stock_csv\ExtractArt_" + constr_date + > ".csv" > > *********** Be careful I have put this command DbeInfo in pgm dbesys.prg > *********** DbeInfo(COMPONENT_DATA, DELDBE_FIELD_TOKEN,";" ) > > DbExport(cFileCsv,; > {"EAN","Reference","libelle","quantite","prixttc"},; > ,,,,,"DELCDX") > > The result of the runing in the txt is that : > > "4005086141896";"14189";"CHIMPANZE MALE";"1";"5.50" > "4005086144064";"14406";"SOURIS BLANCHE";"4";"3.99" > "4005086144071";"14407";"GRENOUILLE";"7";"4.50" > > Missing the end character ";" > > Have some idea ? > > > Thanks a lot > > |