Link to Text with Unknown Headers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peridian
    New Member
    • Dec 2006
    • 72

    Link to Text with Unknown Headers

    Hello,

    Is there a way to setup an Import/LinkTable specification to import/link a delimited text file regardless of the headers in the file, but still retain the header names?

    I've got multiple incoming files that are text files, but delimited by differing things (e.g. tabs, commas, pipes, etc.). Some of the data in these files needs to be standardised and output in a common file format.

    The headers themselves will be called the same things, but quite which headers will or will not be present in any given file varies.

    I wanted to have a simple import spec for each delimiter, so that for each file I get, I simply tell the database which one to use, and set it going. It could then link the file, test the resulting linked table for which fields are present, and copy the relevant ones into a standard table that can then be used to export out from.

    Unfortunately, the specs seem to require a list of fields to map to. Can a spec be created that just parses a file based on its delimiter, using the first row for headers, but not paying attention to what those headers are?

    Regards,
    Rob.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Have you tried using the TransferText() Method? The 2nd Argument is the Specification Name, and the 5th Argument is a Boolean Value indicating whether or not the 1st Row consists of Field Names. The general syntax is listed below:

    [CODE=text]
    expression.Tran sferText(Transf erType, SpecificationNa me, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)[/CODE]
    Example:
    [CODE=vb]DoCmd.TransferT ext(acImportDel im, "Your Specification Name", "Table Name ti Import to, Absolute Path to Text File, 1st Row Has Field Names? (-1 or 0), HTMLTableName, CodePage)[/CODE]

    Comment

    • peridian
      New Member
      • Dec 2006
      • 72

      #3
      Originally posted by ADezii
      Have you tried using the TransferText() Method? The 2nd Argument is the Specification Name, and the 5th Argument is a Boolean Value indicating whether or not the 1st Row consists of Field Names. The general syntax is listed below:

      [CODE=text]
      expression.Tran sferText(Transf erType, SpecificationNa me, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)[/CODE]
      Example:
      [CODE=vb]DoCmd.TransferT ext(acImportDel im, "Your Specification Name", "Table Name ti Import to, Absolute Path to Text File, 1st Row Has Field Names? (-1 or 0), HTMLTableName, CodePage)[/CODE]
      That's what I was using. Unfortunately, the problem is the specification itself.

      You can specify the specification, and I was going to do this to pick the relevent spec for the file type.

      Unfortunately, I could not set up the spec to ignore the names of the headers. If you set up a spec, it then requires all files you use that with to have the same headers as well. If not, it simply takes the columns in your new file as though they were the same.

      I need the spec to save with only the fact that it is a delimited file, regardless of the headers themselves.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by peridian
        That's what I was using. Unfortunately, the problem is the specification itself.

        You can specify the specification, and I was going to do this to pick the relevent spec for the file type.

        Unfortunately, I could not set up the spec to ignore the names of the headers. If you set up a spec, it then requires all files you use that with to have the same headers as well. If not, it simply takes the columns in your new file as though they were the same.

        I need the spec to save with only the fact that it is a delimited file, regardless of the headers themselves.
        I guess you could always resort to basic, low level, I/O Functions to bring the delimited file in.

        Comment

        Working...