OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Database connection to a fixed width flat file

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Fri Mar 11, 2005 7:22 am    Post subject: Database connection to a fixed width flat file Reply with quote

I know how to connect to a delimited text file...
Code:
  sURL = "sdbc:flat:" & GetSourceCodeDir() & "whatever.csv"
  oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
  oDriver = oManager.getDriverByURL(sURL)
  AppendProperty(oParms(), "Extension", "csv")
  AppendProperty(oParms(), "HeaderLine", False)
  AppendProperty(oParms(), "FieldDelimiter", ",")
  AppendProperty(oParms(), "StringDelimiter", """")
  AppendProperty(oParms(), "DecimalDelimiter", ".")
  AppendProperty(oParms(), "ThousandDelimiter", ",")
  oCon = oManager.getConnectionWithInfo(sURL, oParms())

If the file is NOT delimited, however, I do not know how to create a database connection to the file. I do know that there is a "FixedLength" property, but the description is as follows:
Quote:
True when all occurrences of "?" as a parameter name will be replaced by a valid parameter name. This is necessary, because some drivers mix the order of the parameters.

I assume that I will need to read the file into a Calc document and then use that as my data source...
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Wed Mar 16, 2005 2:02 pm    Post subject: Reply with quote

I decided that you probably can not do this, so I wrote a macro that imports the fixed width file into a Calc document and then writes it out as both a delimited document and a Calc document. I can then access either of these formats as I deisre....
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group