从多个文件夹和子文件夹导入CSV和位置 [英] Import CSVs and location from multiple folders and sub folders

查看:108
本文介绍了从多个文件夹和子文件夹导入CSV和位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试从包括子文件夹在内的多个文件夹中导入大量CSV。问题是我需要用每个文件夹中的文件内容记录文件夹名称。


我可以从一个文件夹导入文件名和内容,但不能多个。


我可以导入完整的目录列表,包括文件夹/子文件夹名称,但不能导入实际文件的内容。我使用了http://allenbrowne.com/ser-59alt.html fofull位置的功能。


如果我有一个单独的文件的完整路径我需要单独一个表,我可以用这个循环来导入文件吗?


我已经尝试了我在这个主题上找到的所有内容并相信我非常接近:)


谢谢所有

Gareth

Hi,

I am trying to import a number of CSV''s from a number of folders including subfolders. The snag is that I need to record the folder name with the file contents from each folder.

I can import the file name and contents when it is from one folder, but not multiple.

I am able to import the full directory list including the folder/subfolder names but not the contents of the actual files. I have used a function from http://allenbrowne.com/ser-59alt.html fofull location for this.

If i have the full path of the files I need in a seperate table, can I use this to loop through to import the files?

I have tried everything I have found on the subject and believe I''m very close :)

Thanks all
Gareth

推荐答案

这将获得满足您在文件夹中的条件的所有文件名子文件夹。


如果你有一个例程来导入数据,那就把它放在Debug语句的去处

This will get all the file names that meet your criteria in folders and subfolders.

If you have a routine to import the data, put that in where the Debug statement goes

展开 | 选择 | Wrap < span class =codeDivider> | 行号


AIRCODE 示例:
  1. 让我们假设您拥有下面非常简单的表结构和数据:
  1. Let''s assume that you have the very simple Table Structure and Data below:
展开 | 选择 | Wrap | 行号


感谢您的回复。我尝试了AIRCODE中的代码,现在我已经90%了。我有一个包含CSV内容的表列表,每个表名都与目录表中路径的ID相对应。


我试过并试图找到一种方法将表名与目录表的ID相关联。有办法做到这一点吗?我认为它将涉及某种INSERT INTO查询,我会将tablename插入到相应的表中。


我试图寻找一个函数来遍历所有表并添加表表格的名称。


这可以通过VBA或函数来实现吗?
Thanks both for replying. I tried the code from AIRCODE and I am 90% there now.I have a list of tables with the contents of the CSV''s, and each table name corresponds with the ID of the path in the directory table.

I have tried and tried however to find a way of linking the table name with the ID of the directory table. Is there a way of doing this? I presume it will involve some sort of INSERT INTO query where I would insert the tablename into the corresponding table.

I have tried looking for a function to loop through all tables and add the table name to the table.

Is this possible via VBA or a function do you think?


这篇关于从多个文件夹和子文件夹导入CSV和位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆