简体   繁体   English

从 URL POWER QUERY 获取文件名

[英]Get filename from a URL POWER QUERY

I am trying to query multiple csv files from a URL using power query in excel.我正在尝试使用 excel 中的电源查询从 URL 查询多个 csv 文件。 I am able to download the content.我可以下载内容。 But I want to add another column with the filename.但我想用文件名添加另一列。

Can anyone shed some light on how I can do it?任何人都可以对我如何做到这一点有所了解吗?

Here is a sample URL.这是一个示例 URL。

https://www.punters.com.au/form-guide/spreadsheet-1175858 https://www.punters.com.au/form-guide/spreadsheet-1175858

The filename of this link would be "20210716-geelong-r01.csv".此链接的文件名为“20210716-geelong-r01.csv”。 Opening the link will download the file with this filename.打开链接将下载具有此文件名的文件。

Query I have so far below.到目前为止,我有以下查询。

let
    Source = Table.FromColumns({Lines.FromBinary(Web.Contents("https://www.punters.com.au/form-guide/spreadsheet-1175858"), null, null, 65001)}),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3", "Column1.4", "Column1.5", "Column1.6", "Column1.7", "Column1.8", "Column1.9", "Column1.10", "Column1.11", "Column1.12", "Column1.13", "Column1.14", "Column1.15", "Column1.16", "Column1.17", "Column1.18", "Column1.19", "Column1.20", "Column1.21", "Column1.22", "Column1.23", "Column1.24", "Column1.25", "Column1.26", "Column1.27", "Column1.28", "Column1.29", "Column1.30", "Column1.31", "Column1.32", "Column1.33", "Column1.34", "Column1.35", "Column1.36", "Column1.37", "Column1.38", "Column1.39", "Column1.40", "Column1.41", "Column1.42", "Column1.43", "Column1.44", "Column1.45", "Column1.46", "Column1.47", "Column1.48", "Column1.49", "Column1.50", "Column1.51", "Column1.52", "Column1.53", "Column1.54", "Column1.55", "Column1.56", "Column1.57", "Column1.58", "Column1.59", "Column1.60", "Column1.61", "Column1.62", "Column1.63", "Column1.64", "Column1.65", "Column1.66", "Column1.67", "Column1.68", "Column1.69", "Column1.70", "Column1.71", "Column1.72", "Column1.73", "Column1.74", "Column1.75", "Column1.76", "Column1.77", "Column1.78", "Column1.79", "Column1.80", "Column1.81", "Column1.82", "Column1.83", "Column1.84", "Column1.85", "Column1.86", "Column1.87", "Column1.88", "Column1.89", "Column1.90", "Column1.91", "Column1.92", "Column1.93", "Column1.94", "Column1.95", "Column1.96", "Column1.97", "Column1.98", "Column1.99", "Column1.100", "Column1.101", "Column1.102", "Column1.103", "Column1.104", "Column1.105", "Column1.106", "Column1.107", "Column1.108", "Column1.109", "Column1.110", "Column1.111", "Column1.112", "Column1.113", "Column1.114", "Column1.115", "Column1.116", "Column1.117", "Column1.118", "Column1.119", "Column1.120", "Column1.121", "Column1.122", "Column1.123", "Column1.124", "Column1.125", "Column1.126", "Column1.127", "Column1.128", "Column1.129", "Column1.130"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", type text}, {"Column1.4", type text}, {"Column1.5", type text}, {"Column1.6", type text}, {"Column1.7", type text}, {"Column1.8", type text}, {"Column1.9", type text}, {"Column1.10", type text}, {"Column1.11", type text}, {"Column1.12", type text}, {"Column1.13", type text}, {"Column1.14", type text}, {"Column1.15", type text}, {"Column1.16", type text}, {"Column1.17", type text}, {"Column1.18", type text}, {"Column1.19", type text}, {"Column1.20", type text}, {"Column1.21", type text}, {"Column1.22", type text}, {"Column1.23", type text}, {"Column1.24", type text}, {"Column1.25", type text}, {"Column1.26", type text}, {"Column1.27", type text}, {"Column1.28", type text}, {"Column1.29", type text}, {"Column1.30", type text}, {"Column1.31", type text}, {"Column1.32", type text}, {"Column1.33", type text}, {"Column1.34", type text}, {"Column1.35", type text}, {"Column1.36", type text}, {"Column1.37", type text}, {"Column1.38", type text}, {"Column1.39", type text}, {"Column1.40", type text}, {"Column1.41", type text}, {"Column1.42", type text}, {"Column1.43", type text}, {"Column1.44", type text}, {"Column1.45", type text}, {"Column1.46", type text}, {"Column1.47", type text}, {"Column1.48", type text}, {"Column1.49", type text}, {"Column1.50", type text}, {"Column1.51", type text}, {"Column1.52", type text}, {"Column1.53", type text}, {"Column1.54", type text}, {"Column1.55", type text}, {"Column1.56", type text}, {"Column1.57", type text}, {"Column1.58", type text}, {"Column1.59", type text}, {"Column1.60", type text}, {"Column1.61", type text}, {"Column1.62", type text}, {"Column1.63", type text}, {"Column1.64", type text}, {"Column1.65", type text}, {"Column1.66", type text}, {"Column1.67", type text}, {"Column1.68", type text}, {"Column1.69", type text}, {"Column1.70", type text}, {"Column1.71", type text}, {"Column1.72", type text}, {"Column1.73", type text}, {"Column1.74", type text}, {"Column1.75", type text}, {"Column1.76", type text}, {"Column1.77", type text}, {"Column1.78", type text}, {"Column1.79", type text}, {"Column1.80", type text}, {"Column1.81", type text}, {"Column1.82", type text}, {"Column1.83", type text}, {"Column1.84", type text}, {"Column1.85", type text}, {"Column1.86", type text}, {"Column1.87", type text}, {"Column1.88", type text}, {"Column1.89", type text}, {"Column1.90", type text}, {"Column1.91", type text}, {"Column1.92", type text}, {"Column1.93", type text}, {"Column1.94", type text}, {"Column1.95", type text}, {"Column1.96", type text}, {"Column1.97", type text}, {"Column1.98", type text}, {"Column1.99", type text}, {"Column1.100", type text}, {"Column1.101", type text}, {"Column1.102", type text}, {"Column1.103", type text}, {"Column1.104", type text}, {"Column1.105", type text}, {"Column1.106", type text}, {"Column1.107", type text}, {"Column1.108", type text}, {"Column1.109", type text}, {"Column1.110", type text}, {"Column1.111", type text}, {"Column1.112", type text}, {"Column1.113", type text}, {"Column1.114", type text}, {"Column1.115", type text}, {"Column1.116", type text}, {"Column1.117", type text}, {"Column1.118", type text}, {"Column1.119", type text}, {"Column1.120", type text}, {"Column1.121", type text}, {"Column1.122", type text}, {"Column1.123", type text}, {"Column1.124", type text}, {"Column1.125", type text}, {"Column1.126", type text}, {"Column1.127", type text}, {"Column1.128", type text}, {"Column1.129", type text}, {"Column1.130", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Num", Int64.Type}, {"Horse Name", type text}, {"Age", Int64.Type}, {"Gender", type text}, {"Handicap Rating", Int64.Type}, {"Career Runs", Int64.Type}, {"Career Wins", Int64.Type}, {"Career Strike Rate", Int64.Type}, {"Career ROI", Int64.Type}, {"Career Placings", Int64.Type}, {"Career Place Strike Rate", type number}, {"Dry Track Runs", Int64.Type}, {"Dry Track Wins", Int64.Type}, {"Dry Track Strike Rate", Int64.Type}, {"Dry Track ROI", Int64.Type}, {"Wet Track Runs", Int64.Type}, {"Wet Track Wins", Int64.Type}, {"Wet Track Strike Rate", Int64.Type}, {"Wet Track ROI", Int64.Type}, {"Average Prize Money", Int64.Type}, {"Career Prize Money", Int64.Type}, {"Best Fixed Odds", type number}, {"BetEasy Odds", type text}, {"Weight", type number}, {"Weight Carried", type number}, {"Barrier", Int64.Type}, {"Prize Money", Int64.Type}, {"This Track Runs", Int64.Type}, {"This Track Wins", Int64.Type}, {"This Track Strike Rate", Int64.Type}, {"This Track ROI", Int64.Type}, {"This Track Places", Int64.Type}, {"This Track Place Strike Rate", type number}, {"This Distance Runs", Int64.Type}, {"This Distance Wins", Int64.Type}, {"This Distance Strike Rate", Int64.Type}, {"This Distance ROI", Int64.Type}, {"This Distance Places", Int64.Type}, {"This Distance Place Strike Rate", Int64.Type}, {"This Track Distance Runs", Int64.Type}, {"This Track Distance Wins", Int64.Type}, {"This Track Distance Strike Rate", Int64.Type}, {"This Track Distance ROI", Int64.Type}, {"This Track Distance Places", Int64.Type}, {"This Track Distance Place Strike Rate", Int64.Type}, {"This Condition Runs", Int64.Type}, {"This Condition Wins", Int64.Type}, {"This Condition Strike Rate", Int64.Type}, {"This Condition ROI", Int64.Type}, {"This Condition Places", Int64.Type}, {"This Condition Place Strike Rate", type number}, {"Jockey", type text}, {"Apprentice", type text}, {"Jockey Weight Claim", type number}, {"Jockey Last 100 Horse Earnings", Int64.Type}, {"Jockey Last 100 Avg Horse Earnings", Int64.Type}, {"Jockey Last 100 Starts", Int64.Type}, {"Jockey Last 100 Wins", Int64.Type}, {"Jockey Last 100 Strike Rate", Int64.Type}, {"Jockey Last 100 ROI", Int64.Type}, {"Jockey Last 100 Places", Int64.Type}, {"Jockey Last 100 Place Strike Rate", Int64.Type}, {"Jockey 12 Month Horse Earnings", Int64.Type}, {"Jockey 12 Month Avg Horse Earnings", Int64.Type}, {"Jockey 12 Months Starts", Int64.Type}, {"Jockey 12 Months Wins", Int64.Type}, {"Jockey 12 Months Strike Rate", type number}, {"Jockey 12 Months ROI", Int64.Type}, {"Jockey 12 Months Places", Int64.Type}, {"Jockey 12 Months Place Strike Rate", type number}, {"Jockey This Season Horse Earnings", Int64.Type}, {"Jockey This Season Avg Horse Earnings", Int64.Type}, {"Jockey This Season Starts", Int64.Type}, {"Jockey This Season Wins", Int64.Type}, {"Jockey This Season Strike Rate", type number}, {"Jockey This Season ROI", Int64.Type}, {"Jockey This Season Places", Int64.Type}, {"Jockey This Season Place Strike Rate", type number}, {"Jockey Last Season Horse Earnings", Int64.Type}, {"Jockey Last Season Avg Horse Earnings", Int64.Type}, {"Jockey Last Season Starts", Int64.Type}, {"Jockey Last Season Wins", Int64.Type}, {"Jockey Last Season Strike Rate", type number}, {"Jockey Last Season ROI", Int64.Type}, {"Jockey Last Season Places", Int64.Type}, {"Jockey Last Season Place Strike Rate", type number}, {"Trainer", type text}, {"Trainer Last 100 Horse Earnings", Int64.Type}, {"Trainer Last 100 Avg Horse Earnings", Int64.Type}, {"Trainer Last 100 Starts", Int64.Type}, {"Trainer Last 100 Wins", Int64.Type}, {"Trainer Last 100 Strike Rate", Int64.Type}, {"Trainer Last 100 ROI", Int64.Type}, {"Trainer Last 100 Places", Int64.Type}, {"Trainer Last 100 Place Strike Rate", type number}, {"Trainer 12 Month Horse Earnings", Int64.Type}, {"Trainer 12 Month Avg Horse Earnings", Int64.Type}, {"Trainer 12 Months Starts", Int64.Type}, {"Trainer 12 Months Wins", Int64.Type}, {"Trainer 12 Months Strike Rate", type number}, {"Trainer 12 Months ROI", Int64.Type}, {"Trainer 12 Months Places", Int64.Type}, {"Trainer 12 Months Place Strike Rate", type number}, {"Trainer This Season Horse Earnings", Int64.Type}, {"Trainer This Season Avg Horse Earnings", Int64.Type}, {"Trainer This Season Starts", Int64.Type}, {"Trainer This Season Wins", Int64.Type}, {"Trainer This Season Strike Rate", type number}, {"Trainer This Season ROI", Int64.Type}, {"Trainer This Season Places", Int64.Type}, {"Trainer This Season Place Strike Rate", type number}, {"Trainer Last Season Horse Earnings", Int64.Type}, {"Trainer Last Season Avg Horse Earnings", Int64.Type}, {"Trainer Last Season Starts", Int64.Type}, {"Trainer Last Season Wins", Int64.Type}, {"Trainer Last Season Strike Rate", type number}, {"Trainer Last Season ROI", Int64.Type}, {"Trainer Last Season Places", Int64.Type}, {"Trainer Last Season Place Strike Rate", type number}, {"Last Start Finish Position", Int64.Type}, {"Last Start Margin", type number}, {"Last Start Distance", type text}, {"Last Start Distance Change", Int64.Type}, {"Last Start Prize Money", Int64.Type}, {"Form Guide Url", type text}, {"Horse Profile Url", type text}, {"Jockey Profile Url", type text}, {"Trainer Profile Url", type text}, {"Finish Result (Updates after race)", Int64.Type}, {"Column130", type text}})
in
    #"Changed Type1"

在此处输入图片说明

Thanks in advance for any help.在此先感谢您的帮助。

Use this formula in Power Query在 Power Query 中使用此公式

= Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", type text}, {"Column1.4", type text}, {"Column1.5", type text}, {"Column1.6", type text}, {"Column1.7", type text}, {"Column1.8", type text}, {"Column1.9", type text}, {"Column1.10", type text}, {"Column1.11", type text}, {"Column1.12", type text}, {"Column1.13", type text}, {"Column1.14", type text}, {"Column1.15", type text}, {"Column1.16", type text}, {"Column1.17", type text}, {"Column1.18", type text}, {"Column1.19", type text}, {"Column1.20", type text}, {"Column1.21", type text}, {"Column1.22", type text}, {"Column1.23", type text}, {"Column1.24", type text}, {"Column1.25", type text}, {"Column1.26", type text}, {"Column1.27", type text}, {"Column1.28", type text}, {"Column1.29", type text}, {"Column1.30", type text}, {"Column1.31", type text}, {"Column1.32", type text}, {"Column1.33", type text}, {"Column1.34", type text}, {"Column1.35", type text}, {"Column1.36", type text}, {"Column1.37", type text}, {"Column1.38", type text}, {"Column1.39", type text}, {"Column1.40", type text}, {"Column1.41", type text}, {"Column1.42", type text}, {"Column1.43", type text}, {"Column1.44", type text}, {"Column1.45", type text}, {"Column1.46", type text}, {"Column1.47", type text}, {"Column1.48", type text}, {"Column1.49", type text}, {"Column1.50", type text}, {"Column1.51", type text}, {"Column1.52", type text}, {"Column1.53", type text}, {"Column1.54", type text}, {"Column1.55", type text}, {"Column1.56", type text}, {"Column1.57", type text}, {"Column1.58", type text}, {"Column1.59", type text}, {"Column1.60", type text}, {"Column1.61", type text}, {"Column1.62", type text}, {"Column1.63", type text}, {"Column1.64", type text}, {"Column1.65", type text}, {"Column1.66", type text}, {"Column1.67", type text}, {"Column1.68", type text}, {"Column1.69", type text}, {"Column1.70", type text}, {"Column1.71", type text}, {"Column1.72", type text}, {"Column1.73", type text}, {"Column1.74", type text}, {"Column1.75", type text}, {"Column1.76", type text}, {"Column1.77", type text}, {"Column1.78", type text}, {"Column1.79", type text}, {"Column1.80", type text}, {"Column1.81", type text}, {"Column1.82", type text}, {"Column1.83", type text}, {"Column1.84", type text}, {"Column1.85", type text}, {"Column1.86", type text}, {"Column1.87", type text}, {"Column1.88", type text}, {"Column1.89", type text}, {"Column1.90", type text}, {"Column1.91", type text}, {"Column1.92", type text}, {"Column1.93", type text}, {"Column1.94", type text}, {"Column1.95", type text}, {"Column1.96", type text}, {"Column1.97", type text}, {"Column1.98", type text}, {"Column1.99", type text}, {"Column1.100", type text}, {"Column1.101", type text}, {"Column1.102", type text}, {"Column1.103", type text}, {"Column1.104", type text}, {"Column1.105", type text}, {"Column1.106", type text}, {"Column1.107", type text}, {"Column1.108", type text}, {"Column1.109", type text}, {"Column1.110", type text}, {"Column1.111", type text}, {"Column1.112", type text}, {"Column1.113", type text}, {"Column1.114", type text}, {"Column1.115", type text}, {"Column1.116", type text}, {"Column1.117", type text}, {"Column1.118", type text}, {"Column1.119", type text}, {"Column1.120", type text}, {"Column1.121", type text}, {"Column1.122", type text}, {"Column1.123", type text}, {"Column1.124", type text}, {"Column1.125", type text}, {"Column1.126", type text}, {"Column1.127", type text}, {"Column1.128", type text}, {"Column1.129", type text}, {"Column1.130", type text}})

It is same as splitting column with delimiter 'comma'它与带有分隔符“逗号”的拆分列相同

You can acheive this using custom column您可以使用自定义列实现此目的

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM