export to a flat unix file 
Author Message
 export to a flat unix file

Is there away to take a table and export not only to a txt file but to make
it a flat file, you can select tab delimited but it still puts the records
on its own line, I would like it on one line, tab delimited.

Does any one know how to do this??

Rob



Sun, 05 Jan 2003 03:00:00 GMT  
 export to a flat unix file
Do you mean, write all the records of the table as one long, tab-delimited
record?  Or, rather, to use a tab character as a record delimiter instead of
the normal CR/LF pair?  I'm no expert, but I think you'd have to do your own
I/O processing using VBA statements like Open, Write (or Print?), and Close,
stepping through the records of the table using a recordset.
--

Dirk Goldgar
(remove NOSPAM from reply address)


Quote:
> Is there away to take a table and export not only to a txt file but to
make
> it a flat file, you can select tab delimited but it still puts the records
> on its own line, I would like it on one line, tab delimited.

> Does any one know how to do this??

> Rob



Sun, 05 Jan 2003 03:00:00 GMT  
 export to a flat unix file

Yes I would like to make a file as one long file with a tab character as the
record delimiter instead of the normal cr/lf pair!!!!  I am not expert
either but do you have any examples of the code that you are describing??

Thx.
Rob

Quote:
> Do you mean, write all the records of the table as one long, tab-delimited
> record?  Or, rather, to use a tab character as a record delimiter instead
of
> the normal CR/LF pair?  I'm no expert, but I think you'd have to do your
own
> I/O processing using VBA statements like Open, Write (or Print?), and
Close,
> stepping through the records of the table using a recordset.
> --

> Dirk Goldgar
> (remove NOSPAM from reply address)



> > Is there away to take a table and export not only to a txt file but to
> make
> > it a flat file, you can select tab delimited but it still puts the
records
> > on its own line, I would like it on one line, tab delimited.

> > Does any one know how to do this??

> > Rob



Sun, 05 Jan 2003 03:00:00 GMT  
 export to a flat unix file
Thanks man it worked great!!!!  It would have took me forever to figure that
out!! He says not an expert...

Quote:
> Here's a routine I just threw together that does what I think you want.
> You'll have to paste it into a standard module.  Then you can invoke by a
> variety of means.

> I'm including the text of the routine in this message, and also attaching
it
> as a file so as to avoid line wraps.

> '---- start of VBA code ----
> Sub ExportUnixText(TableName As String, FileName As String, _
>                     Optional FieldDelim As String = ",")
>     'Export a table or query to a Unix-style text file with tab-separated
> records.
>     'Fields in each record are separated by the optional delimiter passed
as
> the
>     'third argument, which defaults to a comma.
>     '
>     'Arguments:
>     '   TableName   - the name of the table or query to be exported
>     '   FileName    - the fully qualified path and name of the output file
>     '   FieldDelim  - Character(s) to be used as a delimiter between
fields
>     '
>     'Notes:
>     '   If the output file already exists it will be overwritten.
>     '
>     'Author: Dirk Goldgar   Date: 19 July, 2000
>     'License: You may use and redistribute this code freely, so long as
the
>     '   attribution remains intact.

>     On Error GoTo Err_Export

>     Dim rsTable As Recordset
>     Dim lngRecords As Long
>     Dim intFileNo As Integer
>     Dim intFieldNo As Integer

>     Dim strQuote As String
>     Dim strTab As String
>     strQuote = Chr$(34)
>     strTab = Chr$(9)

>     Set rsTable = CurrentDb.OpenRecordset(TableName)
>     intFileNo = FreeFile()
>     Open FileName For Output As #intFileNo

>     With rsTable
>         Do Until .EOF
>             lngRecords = lngRecords + 1
>             For intFieldNo = 0 To .Fields.Count - 1
>                 If intFieldNo > 0 Then Print #intFileNo, FieldDelim;
>                 With .Fields(intFieldNo)
>                     If Not IsNull(.Value) Then
>                         Select Case .Type
>                             Case dbText, dbChar
>                                 Print #intFileNo, strQuote; .Value;
> strQuote;
>                             Case Else
>                                 Print #intFileNo, .Value & "";
>                         End Select
>                     End If
>                 End With
>             Next intFieldNo
>             Print #intFileNo, strTab;
>             .MoveNext
>         Loop
>     End With

>     MsgBox "Finished exporting " & lngRecords & _
>            " records from '" & TableName & "' to '" & FileName & "'.", , _
>            "ExportUnixText"

> Exit_Export:
>     On Error Resume Next
>     rsTable.Close
>     Set rsTable = Nothing
>     If intFileNo <> 0 Then Close intFileNo
>     Exit Sub

> Err_Export:
>     MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation,
_
>             "ExportUnixText"
>     Resume Exit_Export

> End Sub
> '---- end of VBA code ----

> --

> Dirk Goldgar
> (remove NOSPAM from reply address)



> > Yes I would like to make a file as one long file with a tab character as
> the
> > record delimiter instead of the normal cr/lf pair!!!!  I am not expert
> > either but do you have any examples of the code that you are
describing??

> > Thx.
> > Rob


> > > Do you mean, write all the records of the table as one long,
> tab-delimited
> > > record?  Or, rather, to use a tab character as a record delimiter
> instead
> > of
> > > the normal CR/LF pair?  I'm no expert, but I think you'd have to do
your
> > own
> > > I/O processing using VBA statements like Open, Write (or Print?), and
> > Close,
> > > stepping through the records of the table using a recordset.
> > > --

> > > Dirk Goldgar
> > > (remove NOSPAM from reply address)



> > > > Is there away to take a table and export not only to a txt file but
to
> > > make
> > > > it a flat file, you can select tab delimited but it still puts the
> > records
> > > > on its own line, I would like it on one line, tab delimited.

> > > > Does any one know how to do this??

> > > > Rob



Sun, 05 Jan 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Flat File Database for Unix machine

2. HOWTO:Read Flat File from Unix Server

3. Accessing Flat Files in UNIX

4. Accessing Flat Files in UNIX

5. Accessing Flat Files in UNIX

6. HOWTO:Read Flat File from Unix Server

7. Export (flat file through textstream or print#) need to break the fields at column 73

8. Exporting to a flat text file with VB

9. Converting a flat file to a comma delimited file

10. Flat files - managing several files

11. flat combobox with flat dropdown

12. Unix - DOS - Unix conversion

 

 
Powered by phpBB® Forum Software