【问题标题】:Can a single schema.ini definition cover multiple files单个 schema.ini 定义能否涵盖多个文件
【发布时间】:2012-04-18 07:59:00
【问题描述】:

我已经为 CSV 文件定义了一个 schema.ini 文件,但我有多个 CSV,我想对它们使用相同的定义,因为它们是一个序列。

File0.csv
File1.csv
File2.csv
File.etc.csv

我的架构是这样的:

[File*.csv]
Format=Delimited(,)
ColNameHeader=True
col1="Brand Code" Text
col2=Description Text
col3="Display Sequence" Text

【问题讨论】:

  • 看来上面*的想法行不通,有没有人有更好的建议?

标签: c# csv schema


【解决方案1】:

据我所知这是不可能的

-******** 其实是有可能的,这样就可以了。

[file1.csv]
FORMAT = Delimited(#)
ColNameHeader = True
MaxScanRows=10
Col1=...
Col2=...
ColN=...

[File2.csv]
FORMAT = Delimited(#)
ColNameHeader = True
MaxScanRows=10
Col1=...
Col2=...
ColN=...

问候!

【讨论】:

    【解决方案2】:

    您可以根据要上传的文件格式在模块/子例程中定义和编写模式。在运行上传之前,必须运行/调用此模块/子例程以创建模式。 (我的示例使用的是 VB6)

    注意:-Filenametxt 是要上传的文件名

    IntFileHandleLog = FreeFile
    Open App.Path & "schema.ini" For Output As #IntFileHandleLog
    Print #IntFileHandleLog, "[" & FileNameTxt & "]"
    Print #IntFileHandleLog, "Format=FixedLength"
    Print #IntFileHandleLog, "MaxScanRows = 0"
    Print #IntFileHandleLog, "CharacterSet = OEM"
    Print #IntFileHandleLog, "Col1=" & """" & "Name" & """" & "Text Width 20"
    Print #IntFileHandleLog, "Col2=" & """" & "PHONE_NUM" & """" & " Text Width 30"
    Print #IntFileHandleLog, "Col3=" & """" & "PHONE_TYPE" & """" & " Text Width 20"
    Print #IntFileHandleLog, "col4=" & """" & "UserName" & """" & " Text Width 20"
    Print #IntFileHandleLog, "col5=" & """" & "A_STAT" & """" & " Text Width 10"
    Print #IntFileHandleLog, "col6=" & """" & "B_STAT" & """" & " Text Width 10"
    Print #IntFileHandleLog, "col7=" & """" & "RETRY" & """" & "integer width 2"
    Print #IntFileHandleLog, "col8=" & """" & "Birth_Date" & """" & " double width 14"
    Print #IntFileHandleLog, "Col9=" & """" & "Joint_Date" & """" & " double width 14"
    Close #IntFileHandleLog
    

    【讨论】:

      猜你喜欢
      • 2011-09-06
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多