span8
第4排
In this exercise,we'll show how to process multiple CSV files in FME.我们将修改现有的FME工作区,将数据从单个csv文件转换为tableau。工作区已设置为从单个csv文件处理商业许可证数据。Data validation and cleanup is performed before the data is written to Tableau format.但是,there are also a number of other CSV files containing business license data from previous years.我们将设置FME来处理所有这些文件。Then,我们将演示两种写出表格的选项:
选项1:将所有数据写入单个Tableau文件。我们将在Tableau文件中添加一个新字段,该字段保存收集营业执照数据的年份。
Option 2: Write data to multiple Tableau files.将为读取的每个csv文件创建一个tableau文件。
源数据:过去几年.zip
Starting workspace:练习2-startingworkspace.fmwt
Completed workspace:exercise2-multiplesheets.fmwt
We will be using the workspace from the previous exerciseHow to prepare Data for Tableau with FME (Processing Spreadsheets).如果您还没有完成上一个练习并且希望,单击链接转到练习。如果你只对这个练习感兴趣,下载启动模板。在上一个练习中,we already created an excel file to store all our values that need to be cleaned up,删除两个datacleanup.xlsx编写器。
在导航窗格中,展开csv阅读器。双击source csv file参数,然后打开高级浏览器。Click on "Select Multiple Folders/Files..." Navigate to the folder containing the four CSV files,然后选择它。从该文件夹中读取扩展名为.csv的文件。删除.gz文件和.txt文件,和以前的.csv文件,我们只对PastYears文件夹中的.csv文件感兴趣。
PastYears文件夹中的数据集:
在导航器中更改源csv文件
Select Multiple Folders/Files...then click on the PastYears folder to add it
Now that we've set up the reader,下一步是在画布上设置现有的源功能类型,以处理csv阅读器读取的所有文件。打开编写器功能类型属性。It was originally set up to read the single business license file.Checking the Merge Feature Type option allows this feature type to process all of the CSV files that are read.我们将使用默认的通配符选项合并过滤器和过滤器类型。重要的是要注意,当我们打开合并特征类型时,FME会自动显示一个名为“FME_feature_type”的属性。每个读取的功能都用这个属性标记,which holds the name of the file each feature was read from.我们将很快使用这个属性。读卡器的名称将从商业许可证更改为
Open up the properties of the writer,启用合并功能类型并接受默认值
确认已设置FME以处理该文件夹中的所有csv文件。右键单击源要素类型并检查数据。确认确实读取了该文件夹中的所有4个文件。通过进一步检查单个功能,we see that the name of the file (or feature type) is stored with the feature.
Connect a VertexCreator transformer to the Reader.This will create points with our Latitude and Longitude attributes.对于模式,确保选中“添加点”,然后更改x值以读取经度属性,更改y值以读取经度属性,then click ok.
Add a VertexCreator and set the X and Y Value
If we ran this workspace now,所有的数据都将被写到一个单一的Tableau文件中。在这种情况下,we should create a new attribute to store the year the business license data was collected using a SubStringExtractor.
在attributeManager和writer功能类型之间放置substringxtractor。Set it up to extract the first 4 characters of the fme_feature_type attribute,今年有效。将年份值存储在名为yearcollected的新属性中。
应使用新属性更新目标Tableau架构。
We only want the year from the fme_feature_type,set the Start Index to 0 and End to 3
创建单个Tableau文件,with a new attribute YearCollected.View this file in Tableau to ensure the YearCollected field is populated
View the BusinessLicenses.tde in Tableau to ensure the YearCollected field is populated
It is easy to create a separate Tableau file for every year of business license data.
If you added the SubstringExtractor in Option 1,disable it for Option 2,右键单击变压器并单击“禁用”
Open the properties of the destination schema (Writer).Click on the drop-down next to Table Name,and select fme_feature_type.我们正在指示FME使用这个属性的值作为输出表名,which means,that for every unique value found,a separate file will be created.我们知道,fme_feature_type包含每个功能读取的文件名,and since we are reading 4 CSV files,we expect 4 tableau files to be created.
Open up the .TDE writer and change the Table Name to the attribute fme_feature_type to create 4 files
导航到输出文件夹以确认创建了4个Tableau文件。如果多次运行此翻译完成。In the Writer properties,在“表设置>常规”下,for Table Handling: Drop and Create.
Windows资源管理器中的4个Tableau文件
?2019安全亚搏在线软件公司|Legal