从逗号分隔值 (.CSV) 文件中获取数据。Get data from Comma Separated Value (.CSV) files

逗号分隔值文件(通常称为 .CSV)是简单的文本文件,其中数据行中的每个值用逗号隔开。Comma separated value files, often known as a .CSV, are simple text files with rows of data where each value is separated by a comma. 这些类型的文件可以在相对较小的文件中包含大量数据,使其成为 Power BI的理想数据源。These types of files can contain very large amounts of data within a relatively small file size, making them an ideal data source for Power BI. 你可以在此处下载一个示例 .CSV 文件。You can download a sample .CSV file here.

如果你已有 .CSV 文件,现在就可以将其作为数据集导入到你的 Power BI 网站,在其中你可以开始浏览数据、创建一些仪表板,并与他人共享你的见解。If you have a .CSV, it’s time to get it into your Power BI site as a dataset where you can begin exploring your data, create some dashboards, and share your insights with others.

提示

很多组织使用每天更新的数据输出 .CSV。Many organizations output a .CSV with updated data each day. 若要确保 Power BI 中的数据集与更新后的文件保持同步,请确保该文件以相同的名称保存到 OneDrive 中。To make sure your dataset in Power BI stays in-sync with your updated file, be sure the file is saved to OneDrive with the same name.

保存文件的位置不同会有所差异Where your file is saved makes a difference

本地 -如果你将 .CSV 文件保存到计算机上的本地驱动器中或者组织中的其他位置,则在 Power BI 中,你可以将文件导入到 Power BI。Local - If you save your .CSV file to a local drive on your computer or another location in your organization, from Power BI you can import your file into Power BI. 你的文件实际上一直保存在本地驱动器中,因此整个文件并未真正导入到 Power BI。Your file will actually remain on your local drive, so the whole file isn’t really imported into Power BI. 实际情况则是在 Power BI 中创建的新数据集以及 .CSV 中的数据会加载到数据集中。What really happens is a new dataset is created in Power BI and data from the .CSV file is loaded into the dataset.

OneDrive - 企业 – 如果你有 OneDrive for Business,并且使用登录 Power BI 的同一帐户登录到其中,这是将 .CSV 文件与你在 Power BI 中的数据集、报表和仪表板保持同步的有史以来最有效的方法。由于 Power BI 和 OneDrive 都位于云中,Power BI 大约每小时会连接你在 OneDrive 上的文件一次。OneDrive - Business – If you have OneDrive for Business and you sign into it with the same account you sign into Power BI with, this is by-far the most effective way to keep your .CSV file and your dataset, reports, and dashboards in Power BI in-sync. Because both Power BI and OneDrive are in the cloud, Power BI connects to your file on OneDrive about every hour. 如果发现任何更改,你的数据集、报表和仪表板会在 Power BI 中自动更新。If any changes are found, your dataset, reports, and dashboards are automatically updated in Power BI.

OneDrive - 个人 – 如果你将文件保存到自己的 OneDrive 帐户,你会像使用 OneDrive for Business 那样获得很多相同优势。OneDrive - Personal – If you save your files to your own OneDrive account, you’ll get many of the same benefits as you would with OneDrive for Business. 最大的不同之处在于,当你首次连接至你的文件(使用“获取数据 > 文件 > OneDrive – 个人”)时,你将需要使用 Microsoft 帐户登录 OneDrive,这通常与你用于登录 Power BI 的帐户不同。The biggest difference is when you first connect to your file (using Get Data > Files > OneDrive – Personal) you’ll need to sign in to your OneDrive with your Microsoft account, which is usually different from what you use to sign in to Power BI. 当使用你的 Microsoft 帐户登录 OneDrive 时,请务必选择“使我保持登录状态”选项。When signing into your OneDrive with your Microsoft account, be sure to select the Keep me signed in option. 这样一来,Power BI 将能够大约每小时连接你的文件一次,并确保你在 Power BI 中的数据集同步。This way, Power BI will be able to connect to your file about every hour and make sure your dataset in Power BI is in-sync.

SharePoint 团队网站 – 将 Power BI Desktop 文件保存到 SharePoint 团队网站与保存到 OneDrive for Business 大致相同。SharePoint Team-Sites – Saving your Power BI Desktop files to SharePoint – Team Sites is much the same as saving to OneDrive for Business. 最大的区别是你从 Power BI 连接到文件的方式。The biggest difference is how you connect to the file from Power BI. 你可以指定一个 URL 或连接到根文件夹。You can specify a URL or connect to the root folder.

导入或连接到 .CSV 文件Import or connect to a .CSV file

重要

可以导入 Power BI 的最大文件大小为 1 千兆字节。The maximum file size you can import into Power BI is 1 gigabyte.

  1. 在 Power BI 中的导航窗格中,单击“获取数据”。In Power BI, in the navigator pane, click Get Data.

  2. 在“文件”中,单击“获取”。In Files, click Get.

  3. 查找你的文件。Find your file.

后续步骤Next steps

浏览你的数据 - 将文件中的数据导入 Power BI 后,就可以浏览文件了。Explore your data - Once you get data from your file into Power BI, it's time to explore. 只需右键单击新的数据集,然后单击“浏览”。Just right-click the new dataset and then click Explore.

计划刷新 - 如果你的文件保存到本地驱动器中,你可以设置计划刷新,以便让 Power BI 中的数据集和报表保持最新状态。Schedule refresh - If your file is saved to a local drive, you can setup scheduled refresh so your dataset and reports in Power BI stay up-to-date. 若要了解详细信息,请参阅 Power BI 中的数据刷新To learn more, see Data refresh in Power BI. 如果你的文件保存到 OneDrive 中,Power BI 将大约每小时自动与该文件同步一次。If your file is saved to OneDrive, Power BI will automatically synchronize with it about every hour.