schema.ini file not working for MS Access

前端 未结 3 1561
故里飘歌
故里飘歌 2021-01-29 01:38

I have a bunch of csv files that I import via VBA into tables in Access. I also have a schema.ini file in the same directory as the csv files that I am importing. Despite fields

3条回答
  •  遇见更好的自我
    2021-01-29 01:59

    I think your syntax for field specifications is wrong.
    From http://www.htmlgoodies.com/primers/database/work-with-text-file-data-using-the-microsoft-text-driver-creating-a-csv-data-file.html

    Understanding the Schema.ini file line by line

    Line 5 and above: Specify each column’s Name, Data type, Width if applicable. The general syntax is

    Col(n)=

    Where n is the position of the column in the CSV file, and Width is mandatory only for Text.

    and https://msdn.microsoft.com/en-us/library/ms709353%28VS.85%29.aspx

    The next entry designates fields in a table by using the column number (Coln) option, which is optional for character-delimited files and required for fixed-length files.

    So you can omit Col1=, Col2=, etc. as you did, but the = belongs between Col(n) and the column name, not between name and type. So replace the = by space.

    In addition, INTEGER may not be a valid data type to import into Access - use Short or Long instead. But I'm not sure about that.

    Edit: I haven't actually used this (or if I have, I forgot about it), but from the references I linked it should look:

    [ForClsDatedModel_2015 0702_1004-1254.csv]
    ColNameHeader=True
    Format=CSVDelimited
    "Ticker" TEXT
    "WT Def BSS MF-WT" LONG
    "Cyc BSS MF-WT" DOUBLE
    

    or if that doesn't work, try including Coln - most examples include them, even if it's CSVDelimited:

    [ForClsDatedModel_2015 0702_1004-1254.csv]
    ColNameHeader=True
    Format=CSVDelimited
    Col1="Ticker" TEXT
    Col2="WT Def BSS MF-WT" LONG
    Col3="Cyc BSS MF-WT" DOUBLE
    

提交回复
热议问题