从电源查询中导入.csv文件中选定的列

发布于 2025-02-06 23:49:59 字数 220 浏览 0 评论 0原文

我希望从.CSV文件的变量列表中以已知所需的列标头导入数据,其中一些列有我不需要的列。例如:

文件1可能有: 名称,地址,电子邮件

文件2具有: 名称,地址,电子邮件,cell_phone

我需要将所有CSV文件附加到一个表中,但我只需要名称,地址和电子邮件数据。

这需要是一个动态的解决方案,因为将来数据供应商可能会在其.CSV文件中添加其他新字段,这是我无法控制的。

I'm looking to import data with known required column headers, from a variable list of .csv files, some of which have columns I don't need. For example:

File 1 maybe has:
NAME, ADDRESS, EMAIL

File 2 has:
NAME, ADDRESS, EMAIL, CELL_PHONE

I need to append all csv files into a single table but I only want NAME, ADDRESS, and EMAIL data.

This needs to be a dynamic solution because in future the data supplier may add other new fields in their .csv files, and this is out of my control.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩套路吗 2025-02-13 23:49:59

您可以从CSV文件中组合数据,然后选择要保留的列:

let
    Source = Folder.Files("C:\MyFolder\"),
    #"Filtered Rows" = Table.SelectRows(Source, each [Extension] = ".csv"),
    #"Added CSVdata" = Table.AddColumn(#"Filtered Rows", "CSVdata", each Table.PromoteHeaders(Csv.Document([Content])), type table),
    #"Combined CSVdata" = Table.Combine(#"Added CSVdata"[CSVdata]),
    #"Selected Columns" = Table.SelectColumns(#"Combined CSVdata",{"Project ID", "Material ID", "Material Description"})
in
    #"Selected Columns"

You can combine data from your CSV files then select the columns you want to keep:

let
    Source = Folder.Files("C:\MyFolder\"),
    #"Filtered Rows" = Table.SelectRows(Source, each [Extension] = ".csv"),
    #"Added CSVdata" = Table.AddColumn(#"Filtered Rows", "CSVdata", each Table.PromoteHeaders(Csv.Document([Content])), type table),
    #"Combined CSVdata" = Table.Combine(#"Added CSVdata"[CSVdata]),
    #"Selected Columns" = Table.SelectColumns(#"Combined CSVdata",{"Project ID", "Material ID", "Material Description"})
in
    #"Selected Columns"
一笔一画续写前缘 2025-02-13 23:49:59
  1. 将两个文件都放在一个文件夹中。
  2. 确保列名称是您想要的(名称,地址,电子邮件)。保持其他列。
  3. 打开您要去的模板或文件,从

““在此处”>

  1. 转到菜单data>获取数据>从文件夹中。选择将文件放入的文件夹。然后导入
  2. 然后Excel将自动检测您可以在新窗口中看到的文件。
    您可以单击“变换数据”按钮。

“在此处输入图像说明”

您将在内容和数据的第一列之间看到“组合文件”按钮。单击这并让确定加载数据。您的数据将正确加载。然后,您可以尝试转换数据

  1. Put both files in one folder.
  2. Make sure the Columns names are same the one you want(NAME, ADDRESS, EMAIL). keep other columns as they are.
  3. Open your template or file which you are going import the data from

enter image description here

  1. Go to the menu Data > Get Data> From File >From Folder. select folder that you put the files in. then import
  2. then excel will automatically detect the files you can see in the new window.
    from there you can click on transform Data button.

enter image description here

you will see the combine files button between content and the first column of the data. click on that and make ok to load the data. your data will be loaded correctly. then you can work on transforming the data however you want to

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文