简体   繁体   English

转换表或时间表的数据类型

[英]Converting Datatype of table or timetable

Within a script I am loading data from SQL Server with select and a complex SQL-Statement. 在脚本中,我正在使用select和复杂的SQL语句从SQL Server加载数据。 The returning datatype seems to be table. 返回的数据类型似乎是表。

First I am extracting a timestamp column out of this table and do some fancy filtering, to split the dataset into subsets (device is off for some hours, I like to analyse the data set by set). 首先,我将从该表中提取一个timestamp列,并进行一些花式过滤,以将数据集拆分为子集(设备关闭了几个小时,我喜欢按组分析数据集)。 So far, everything is great. 到目前为止,一切都很好。

Afterwards I would like to fill the subset every time a dataset is missing. 之后,我想在每次缺少数据集时填充子集。 Quite often, the data from a single timestamp is missing, so I would like to insert data with a timetable ('Time'-array is created before): 通常,单个时间戳记中的数据会丢失,因此我想插入带有时间表的数据(之前创建了“时间”数组):

TT = timetable(Time,data(idTracks(i)+1:idTracks(i+1),{'ID',...
    ...
    'positionLatitude','positionLongitude','speed'}));

retime(TT,'regular','linear','TimeStep',dt) 

I got the error message 'All variables in input timetables must be numeric, datetime, or duration when synchronizing using 'linear'.' 我收到错误消息“使用“线性”同步时,输入时间表中的所有变量必须为数字,日期时间或持续时间。” I got that but I know, that in the database, all my columns are defined as float and they all contains numbers. 我知道了,但是我知道,在数据库中,我所有的列都定义为float,并且都包含数字。 I tried to CAST within the SQL-Statement. 我试图在SQL语句中进行CAST。 Does not work. 不起作用。 If I try class(data.id) column by column, I alway get a double in return. 如果我逐列尝试class(data.id),我总是会得到双倍的回报。

How can I easily adjust the datatype, as my timetable has some more columns as mentions in the example (about 30)? 我的时间表有更多列,如示例中所述(约30个),我如何轻松调整数据类型? I would like to avoid to do the transformation column by column, I would like to fix the table or the timetable in one step if possible, but can't find the trick. 我想避免逐列进行转换,如果可能的话,我想一步一步地修复表或时间表,但是找不到窍门。

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

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