我有两个日期以 mm/dd/yyyy 格式保存在文本文件中。 我需要分析此日期范围内的数据并删除所有其他数据。
我怎样才能做到这一点?
以下是如何根据从文本文件读取的日期运行分析的 2 个示例
Names Default To Here( 1 );
// Create a sample data table
dt = New Table( "Example",
Add Rows( 7 ),
New Column( "ACTUAL_SHORT_DATE",
Numeric,
"Continuous",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Set Values(
[3612470400, 3614025600, 3618777600, 3614457600, 3613420800,
3578947200, 3613939200]
),
Set Display Width( 154 )
),
New Column( "Sample Data",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[0.865467654397147, 0.551025322305757, -0.780534757628151,
0.590164622893679, -0.084595197133406, 0.93192690045854,
-0.652714499840696]
)
)
);
// Read the data from the text file
textValue = Load Text File( "C:\Temp\DateRange.txt" );
// Parse out the start and end dates
startDate = Informat( Word( 1, textValue, " " ) );
endDate = Informat( Word( 2, textValue, " " ) );
// Select the data that falls within the start
// and end dates
dt << select where(
:ACTUAL_SHORT_DATE > startDate & :ACTUAL_SHORT_DATE < endDate
);
// Subset
dtSub = dt << Subset(
Selected Rows( 0 ),
Rows( [2, 4, 5, 7] ),
Selected columns only( 0 )
);
// Analyze the data
dtSub << Bivariate( Y( :Sample Data ), X( :ACTUAL_SHORT_DATE ) );
Names Default To Here( 1 );
// Create a sample data table
dt = New Table( "Example",
Add Rows( 7 ),
New Column( "ACTUAL_SHORT_DATE",
Numeric,
"Continuous",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Set Values(
[3612470400, 3614025600, 3618777600, 3614457600, 3613420800,
3578947200, 3613939200]
),
Set Display Width( 154 )
),
New Column( "Sample Data",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[0.865467654397147, 0.551025322305757, -0.780534757628151,
0.590164622893679, -0.084595197133406, 0.93192690045854,
-0.652714499840696]
)
)
);
// Read the data from the text file
textValue = Load Text File( "C:\Temp\DateRange.txt" );
// Parse out the start and end dates
startDate = Informat( Word( 1, textValue, " " ) );
endDate = Informat( Word( 2, textValue, " " ) );
// Select the data that falls outside the start
// and end dates
dt << select where(
:ACTUAL_SHORT_DATE < startDate | :ACTUAL_SHORT_DATE > endDate
);
// Hide and exclude the selected rows
dt << Hide and Exclude;
dt << clear select;
// Analyze the data
dt << Bivariate( Y( :Sample Data ), X( :ACTUAL_SHORT_DATE ) );
感谢您的回复。附加示例文本文件。我的 jmp 表中包含所有数据,其中还包含有效的 JMP 日期列。
1. 文本文件结构是什么样的?
2. 要分析的数据是否已在 JMP 数据表中?
3. 要分析的数据中是否存在有效的 JMP 日期列?
基本上,您要做的就是从文本文件中读取日期。然后找到分析表中满足该要求的所有行,然后将这些行子集到新的数据表中。最后,您将对子集数据表运行分析。
如果您可以提供有关文本文件和数据文件/表结构的更多详细信息,我可能会为您找到解决方案。