MS Access 2003/2007 - 从 VBA 中使用的 csv 文件导入数据的导入规范......验证字段名称?
我有一个使用向导进行的导入,至少足以保存规范。它导入带有标题、引用文本限定符和逗号分隔的 CSV 文件。然后,我在一些由按钮单击事件触发的 vba 中使用导入规范。
以下是我想知道的一些事情:
那么,如果数据中的字段顺序混乱,导入会失败吗?如果数据不包含所有字段导入失败?如果数据中有多余字段导入失败?
那么我可以对导入的数据进行任何类型的验证,以确保字段与规范相同,它们的顺序正确(如果需要的话)等等。
这工作得很好,但我只需注意,如果数据中的某些内容不正常,它无论如何都会导入,并浪费整个时间。
另外...这不是典型的访问设置...这主要是供数据分析师团队将文件导入 mdb...没有前端。
谢谢 贾斯汀
I have an import which I made with the wizard, at least far enough just to save the specification. It imports CSV files, with headers, quote text qualifiers, and comma delimited. I then use the import specification in some vba that fires from a button click event.
Here are some things I am wondering:
So if the fields in the data are out of order the import fails? if the data does not contain all the fields the import fails? if there are extra fields in the data the import fails?
So is there any kind of validation I can do to the data getting imported th ensure that the fields are the same as the spec, they are in the right order (if they need to be), etc.
This works pretty well, but I just see that if something in the data is out of the normal it will import anyway, and throw the whole time off.
Also....this is not a typical access set up...this is mainly for a team of data analysts to import files into a mdb...there is not an front end with this.
thanks
justin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 ADO 记录集检查 CSV 文件。
如果该连接字符串不适合您,请参阅文本文件的连接字符串
You can inspect the CSV file using an ADO recordset.
If that connection string doesn't work for you, see Connection strings for Textfile
我会向他们提供正确格式的受保护电子表格。这种保护确保他们无法更改它。
如果导入失败,请向他们提供错误报告。
I would provide them with a protected spreadsheet in the correct format. The protection ensures that they cannot alter it.
Provide them with the error report if/when it fails to import.