通过 Power BI Desktop 连接到 CSV 文件Connect to CSV files in Power BI Desktop

通过 Power BI Desktop 连接到以逗号分隔的值 (CSV) 文件同连接到 Excel 工作簿非常相似。Connecting to a comma-separated value (CSV) file from Power BI Desktop is a lot like connecting to an Excel workbook. 两者都很简单,这篇文章将对怎样连接到你有权访问的 CSV 文件进行指导。Both are easy, and this article steps you through how to connect to any CSV file to which you have access.

首先,在 Power BI Desktop 中,从“开始”功能区选择“获取数据”>“CSV”。To start with, from Power BI Desktop select Get Data > CSV from the Home ribbon.

从出现的“打开”对话框中选择 CSV 文件。Select your CSV file from the Open dialog that appears.

当你选择“打开”时,Power BI Desktop 将访问该文件,并确定某些文件属性(如文件来源、分隔符类型和用于检测文件数据类型的应有行数)。When you select Open, Power BI Desktop accesses the file and determines certain file attributes, such as the file origin, delimiter type, and how many rows should be used to detect the data types in the file.

这些文件属性和选项将显示在“CSV 导入”对话框窗口顶部的下拉选择列表中,如下所示。These file attributes and options are shown in the drop-down selections at the top of the CSV import dialog window, shown below. 你可以通过从下拉选择器中选择其他选项对所有检测到的设置进行手动更改。You can change any of these detected settings manually, by choosing another option from any of the drop-down selectors.

选择所需选项后,你可以选择“加载”将文件导入 Power BI Desktop,或者你可以选择“编辑”以打开“查询编辑器”,在导入前对数据进行进一步调整和转换。When you’re satisfied with the selections, you can select Load to import the file into Power BI Desktop, or you can select Edit to open Query Editor and further shape or transform the data before importing it.

将数据加载到 Power BI Desktop 后,你将在 Power BI Desktop 中的“报表”视图右侧的“字段”窗格中看到该表及其列(显示为 Power BI Desktop 中的字段)。Once you load the data into Power BI Desktop, you see the table and its columns (which are presented as Fields in Power BI Desktop) in the Fields pane, along the right of the Report view in Power BI Desktop.

以上就是你需要操作的全部步骤 – 现在,CSV 文件中的数据全都在 Power BI Desktop 中了。That’s all you have to do – the data from your CSV file is now in Power BI Desktop.

你可以在 Power BI Desktop 中使用该数据来创建视觉对象、报表或与你可能想要连接和导入的其他数据(如 Excel 工作簿、数据库或任何其他数据源)进行交互。You can use that data in Power BI Desktop to create visuals, reports, or interact with any other data you might want to connect with and import, such as Excel workbooks, databases, or any other data source.

后续步骤Next steps

你可以使用 Power BI Desktop 连接到各种数据。There are all sorts of data you can connect to using Power BI Desktop. 有关数据源的详细信息,请参阅下列资源:For more information on data sources, check out the following resources: