Magic User Group

Magic Wiki-Wakka : ExportDataToCSVFile

HomePage :: CATEGORIES | Index :: Changes :: Comments :: Search :: Login/Register
Most recent edit on 2005-07-08 13:42:26 by GroupsMBM [enhanced format, added "quotes around strings"]

Additions:
Select  Virt  1 vFor Output  ("E")


If you need quotes around strings, you will have to concatenate them as necessary. The previous example would then look like this:
Update  E  Expr='"' & Trim(A) & '",'
Update  E  Expr=Trim(E) & '"' & Trim(D) & '"'


Deletions:
Select Virt 1 vFor Output ("E")



Edited on 2005-06-29 00:20:18 by GroupsMBM [moved the category info]

No differences.


Edited on 2005-06-29 00:19:30 by GroupsMBM [added category]

Additions:
Categories
CategoryHowTo




Edited on 2005-06-28 16:26:59 by GroupsMBM

Additions:

Export Data To .CSV File

Magic Version: Generic. This hasn't really changed in a LONG time!
A default magic export program will generate a "columnar" text file. That is to say, each field that is output will be output to the same horizontal column number, and there will be a lot of spaces output to pad each field. If you would like to output a .CSV file, do the following.
  1. Create a virtual field to use for output, long enough to hold the largest CSV record.
  2. Delete the existing "Class=1 / Detail / Text-based" form
  3. Create a new "Class=1 / Detail / Text-based" form, wide enough to hold the virtual field.
  4. Put the virtual field on the form.
  5. In record suffix, build the CSV output by concatenating each field into the virtual field.
  6. Output the form to the export I/O entry.

    Deletions:
    NOTE: A default magic export program will generate a "columnar" text file. That is to say, each field that is output will be output to the same horizontal column number, and there will be a lot of spaces output to pad each field. If you would like to output a .CSV file, do the following.
Create a virtual field to use for output, long enough to hold the largest CSV record.
Delete the existing "Class=1 / Detail / Text-based" form
Create a new "Class=1 / Detail / Text-based" form, wide enough to hold the virtual field.
Put the virtual field on the form.
In record suffix, build the CSV output by concatenating each field into the virtual field.
Output the form to the export I/O entry.




Edited on 2005-06-28 16:21:04 by GroupsMBM

No differences.


Edited on 2005-06-28 16:20:15 by GroupsMBM

Additions:
Name Alpha 30
Date Of Birth Date 4 'MM/DD/YYYY'
Age Number 3
Zip Code Alpha 10


Deletions:
Name Alpha 30

Date Of Birth Date
4 'MM/DD/YYYY' Age
Number 3
Zip Code Alpha 10





Edited on 2005-06-28 16:19:54 by GroupsMBM

Additions:
Name Alpha 30

Date Of Birth Date
4 'MM/DD/YYYY' Age
Number 3
Zip Code Alpha 10



Deletions:

Warning: Invalid argument supplied for foreach() in /is/htdocs/29056/www.ng-sw.de/mg-wikka/actions/table.php on line 29




Edited on 2005-06-28 16:19:07 by GroupsMBM

Additions:

Warning: Invalid argument supplied for foreach() in /is/htdocs/29056/www.ng-sw.de/mg-wikka/actions/table.php on line 29


Deletions:

Name Alpha 30
Date Of Birth Date 4 'MM/DD/YYYY'
Age Number 3
Zip Code Alpha 10




Edited on 2005-06-28 16:15:55 by GroupsMBM

Additions:
Name Alpha 30
Date Of Birth Date 4 'MM/DD/YYYY'
Age Number 3
Zip Code Alpha 10


Deletions:
Name Alpha 30
Date Of Birth Date 4 'MM/DD/YYYY'
Age Number 3 '#'
Zip Code Alpha 10




Edited on 2005-06-28 16:14:28 by GroupsMBM

Additions:

Date Of Birth Date 4 'MM/DD/YYYY'
Zip Code Alpha 10

Select Real 2 Date Of Birth ("B")
Select Real 4 Zip Code ("D")
Select Virt 1 vFor Output ("E")


Deletions:
DateOfBirth Date 4 'MM/DD/YYYY'
ZipCode Alpha 10
Select Real 2 DateOfBirth ("B")
Select Real 4 ZipCode ("D")
Select Virt 1 vForOutput ("E")




Oldest known version of this page was edited on 2005-06-28 16:09:47 by GroupsMBM []
Page view:
NOTE: A default magic export program will generate a "columnar" text file. That is to say, each field that is output will be output to the same horizontal column number, and there will be a lot of spaces output to pad each field. If you would like to output a .CSV file, do the following.

These instructions assume that you are starting with a default magic export program.

Create a virtual field to use for output, long enough to hold the largest CSV record.
Delete the existing "Class=1 / Detail / Text-based" form
Create a new "Class=1 / Detail / Text-based" form, wide enough to hold the virtual field.
Put the virtual field on the form.
In record suffix, build the CSV output by concatenating each field into the virtual field.
Output the form to the export I/O entry.

As an example, let's say that you would like to create a .CSV file with the following fields:
Name Alpha 30
DateOfBirth Date 4 'MM/DD/YYYY'
Age Number 3 '#'
ZipCode Alpha 10

The record main will look like this:

Select Real 1 Name ("A")
Select Real 2 DateOfBirth ("B")
Select Real 3 Age ("C")
Select Real 4 ZipCode ("D")
Select Virt 1 vForOutput ("E")

The record suffix will look like this:

Update E Expr=Trim(A) & ','
Update E Expr=Trim(E) & Trim(dstr(B,'MM/DD/YYYY')) & ','
Update E Expr=Trim(E) & Trim(str(C,'3')) & ','
Update E Expr=Trim(E) & Trim(D)
Outpuf Form=3 I/O=1
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki trunk
Page was generated in 0.1735 seconds