Is there a way to convert a 4D database to a free SGBD like MySQL ? If no, is there a way to export tables from a 4D database to a csv file ?
Convert, no. You can export data using either the export or quick report editor.
if you are using a +v15 version you could export every table to json using something like this:
$jsontext:=JSON Stringify(ds.YourTable.all())
C_TIME(vhDoc)
vhDoc:=Create document("";"json") // Create new document called Note
If (OK=1)
SEND PACKET(vhDoc;$jsontext) // Write one word in the document
CLOSE DOCUMENT(vhDoc) // Close the document
SHOW ON DISK(Document)
End if
The answer for the first question: how to export all data from a 4D database to MySQL (or similar SQL DBMS)
SQL EXPORT DATABASE("";0) // the second parameter = 0 to let export ALL
tables
This create a structure of folders with names as table names and containing a file named "SQLExport.sql" with SQL dumps.
SQL EXPORT DATABASE command page in 4d doc
Related
I have a table in Cassandra DB and one of the column has value in JSON format. I am using Datastax DevCenter for querying the DB and when I try to export the result to CSV, JSON value gets broken to separate column wherever there is coma(,). I even tried to export from command prompt without giving and delimiter, that too resulted in broken JSON value.
Is there anyway to achieve this task?
Use the COPY command to export the table as a whole with a different delimiter.
For example :
COPY keyspace.your_table (your_id,your_col) TO 'your_table.csv' WITH DELIMETER='|' ;
Then filter on this data programmatically in whatever way you want.
I am trying to export a table from MySQL to excel in Codeigniter using PHPExcel. But for a column with varchar datatype [16 digits], the result in excel become something like a,bE+15. For example for 3374142005140004 in MySQL, in excel from the export it became 3,37414E+15 or 3374142005140000, so I lost the last digit value which is 4. The best file type to export to is OpenDocumentSpreadsheet (.ODS) [Tried it manually from xampp export file]. But PHPExcel doesn't have OOCalc writer yet. And I don't know how to integrate PHPMYADMIN export in CodeIgniter app. So, If anyone have the solution for this problem, please please share the solution. Thanks in advance for any help/suggestion.
If your string value is longer than a PHP integer, then you'll need to save it as a string using setCellValueExplicit() instead of setCellValue()
PHPExcel does allow you to write OpenOfficeXML files using the OpenDocument Writer
I'm generating a table in SAS and exporting it to a Microsoft Access database (mdb). Right now, I do this by connecting to the database as a library:
libname plus "C:\...\plus.mdb";
data plus.groupings;
set groupings;
run;
However, SAS doesn't export the variable formats to the database, so I end up with numeric values in a table that I want to be human-readable. I've tried proc sql with the same effect. What can I do to get the formatted data into Access?
What I've tried so far:
Plain libname to mdb, data step (as above)
Plain libname to mdb, proc sql create table
OLE DB libname (as in Rob's reference), data step
OLE DB libname, proc sql create table
There's a bunch of alternative connection types here, maybe one of those will work?:
http://support.sas.com/techsup/technote/ts793.pdf
What's working right now:
Because SAS does preserve formatted values in csv, I'm exporting the table to a csv file that feeds a linked table in the Access database. This seems less than ideal, but it works. It's weird that SAS clearly has the capacity to export formatted values, but doesn't seem to document it.
proc export
data= groupings
outfile= "C:\...\groupings.csv"
dbms= CSV
replace;
putnames= yes;
run;
A seeming disadvantage of this approach is that I have to manually recreate the table if I add a new field. If I could drop/create in proc sql, that wouldn't be an issue.
From SAS support: if you create a SQL view using put() to define the variables, you can then export the view to the database and maintain the formatted values. Example:
libname plus "C:\...\plus.mdb";
proc sql;
create view groupings_view as (
SELECT put(gender, gender.) AS gender,
put(race, race.) AS race,
... etc.
FROM groupings
);
create table plus.groupings as (
SELECT *
FROM groupings_view
);
quit;
I wasn't able to just create the view directly in Access - it's not entirely clear to me that Jet supports views in a way that SAS understands, so maybe that's the issue. At any rate, the above does the trick for the limited number of variables I need to export. I can imagine automating the writing of such queries with a funky macro working on the output of proc contents, but I'm terribly grateful I don't have to do that...
How to export sqlite into CSV using RSqlite?
I am asking because I am not familiar with database files, so I want to convert it using R.
It may be very simple, but I haven't figure out.
not quite sure if you have figured this out. I am not quite sure how to do it within R either but it seems pretty simple to export to csv using SQLite itself, or by writing out csv from the database you have loaded to R.
In SQLite, you can do something like this at your command prompt
>.mode csv
>.export output.csv
>.header on
>select * from table_name;
>.exit
SQLite will automatically wrote out your table to a output.csv file
If the table is not too large, you can first export it into an data frame or matrix in R using the dbGetQuery or the dbSendQuery and fetch commands. Then, you can write that data frame as a .csv file.
my.data.frame <- dbGetQuery(My_conn, "SELECT * FROM My_Table")
write.csv(my.data.frame, file = "MyFileName.csv", ...)
I have an access97 database and I am trying to write some code to export to a CSV file - (I am new to VBA).
I have this working however, there is one field that I am exporting that is a currency so in it for example is £3,456.00 - when I export to the CSV I get exactly this - however I need it to just be the number i.e 3456.00.
On a similar issue - I have the date as dd/mm/yyyy and I wonder if there is a way to convert that in VBA to yyyy-mm-dd?
Please bear in mind any solutions has to be simple due to my limited knowledge!
Sorry about the delay; seemingly easy things took longer. As I assumue from your:
DoCmd.TransferText acExportDelim, "olly_csv", "olly aorder export", "\\10.0.0.38\nw_upload\aorders.csv"
that you have an export specification "olly_csv" that determines how to export the
resultset of the SELECT query "olly aorder export" to the file "aorders.csv"
in the destination folder "\10.0.0.38\nw_upload".
The easy way to export the CURRENCY field(s) as plain Double/Float/Single number
and the DATE field(s) with a format of your choice (dd/mm/yyyy) would be to
request just that in the export specification. I found no way to do that in Access
2000 (As far as I can see, there are limited ways to pick date formats, but the features of the Import Wizard to deal with the types of columns are not implemented by the
Export Wizard).
The Docs about "TransferText" (sorry, Access 2003) state:
SpecificationName Optional Variant. A string expression that's the name of
an import or export specification you've created and saved in the current
database. For a fixed-width text file, you must either specify an argument or
use a schema.ini file, which must be stored in the same folder as the
imported, linked, or exported text file. To create a schema file, you can use
the text import/export wizard to create the file. For delimited text files
and Microsoft Word mail merge data files, you can leave this argument blank
to select the default import/export specifications.
Now there are to schools of Microsoft Docs philology: The optimists will read
that as: If you don't pass an export specification and have a suitable schema.ini
file, then the export process will adhere to the specs in the file. The pessimists
will say: Microsoft never agreed to fullfill your pipe dreams - if you don't
specify an argument for a non-fixed-width file, the TransferText command will
use some obscure default export specification (please pay a consultant to
seek and change it).
Let's be optimistic!
So create a schema.ini file with a section for "aorders.csv". For my tests I
used a table
Tabelle: OlliesOrders
Name Typ Größe
OrderId Long Integer 4
Amount Währung 8
DateDue Datum/Uhrzeit 8
(sorry about the German; Amount is Currency, DateDue Date/Time). For that table
the schema.ini section looks like:
[aorders.csv]
ColNameHeader=True
CharacterSet=1252
Format=Delimited(;)
DateTimeFormat=dd/mm/yyyy
Col1=OrderId Integer
Col2=Amount Float
Col3=DateDue Date
You'll have to adapt this example to your fields. Do you want column headers? Is the
windows codepage ok? What about field separators? I had to use ; (German locale), you
may need "Format=CSVDelimited". Look here for some background. Then call
DoCmd.TransferText acExportDelim, , "olly aorder export", "\\10.0.0.38\nw_upload\aorders.csv"
and check if optimists rule.
For pessimists:
Create a new query on the table to export (from). Change the type to Ausführung/Execute (?)
and edit the SQL until it looks like:
SELECT OlliesOrders.* INTO [aorders.csv] IN 'M:\trials\23forum\SOTrials\txt' [TEXT;] FROM OlliesOrders;
resp.:
SELECT YourFieldsList INTO [aorders.csv] IN '\\10.0.0.38\nw_upload' [TEXT;] FROM YourTable;
and execute it (from the query window or a macro/module Sub). My result:
"OrderId";"Amount";"DateDue"
1;1411,09;29/04/2011
2;123,45;13/04/2011
ADDED: Evidence for my claim, that you can't specify types in the Export Wizard:
Export
Import