data-conversion

Convert age entered as 'X Weeks, Y Days, Z hours' in R

岁酱吖の 提交于 2020-01-04 05:59:52
问题 I have an age variable containing observations that follow this (inconsistent) format: 3 weeks, 2 days, 4 hours 4 weeks, 6 days, 12 hours 3 days, 18 hours 4 days, 3 hours 7 hours 8 hours I need to convert each observation to hours using R. I have used strsplit(vector, ',') to split the variable at each comma. I am running trouble because splitting each observation at the ',' yields anywhere from 1 to 3 entries for each observation. I do not know how to properly index these entries so that I

How to construct const integers from literal byte expressions?

淺唱寂寞╮ 提交于 2020-01-04 04:30:28
问题 Is there a way to construct a const integer from a literal byte expression, either using a byte string or a macro which constructs the integer? For example: const MY_ID: u16 = u16_code!(ID); const MY_WORD: u32 = u32_code!(WORD); const MY_LONG: u64 = u64_code!(LONGWORD); Or something similar, passing in b"ID" instead of ID ? * It should fail to compile when the wrong number of characters are passed too, something I couldn't figure out how to achieve when using bit-shifting on a literal byte

How to convert string to date type in MarkLogic?

时间秒杀一切 提交于 2020-01-03 21:50:05
问题 I am currently having some challenge in converting String data type to Date type. I used the MarkLogic JavaScript function xdmp.parseDateTime , but I am always getting the error below: Scenario: Convert "2013-04-21" (string) to 2013-04-21 (date type) Code: let targetDateString = "2013-04-21"; let targetDate = new Date(); targetDate = xdmp.parseDateTime("[Y0001]-[M01]-[D01]", xs.date(targetDate)); Error Info: XDMP-ARGTYPE: xdmp.parseDateTime("[Y0001]-[M01]-[D01]", xs.date("2013-04-21")) --

How to convert string to date type in MarkLogic?

对着背影说爱祢 提交于 2020-01-03 21:47:53
问题 I am currently having some challenge in converting String data type to Date type. I used the MarkLogic JavaScript function xdmp.parseDateTime , but I am always getting the error below: Scenario: Convert "2013-04-21" (string) to 2013-04-21 (date type) Code: let targetDateString = "2013-04-21"; let targetDate = new Date(); targetDate = xdmp.parseDateTime("[Y0001]-[M01]-[D01]", xs.date(targetDate)); Error Info: XDMP-ARGTYPE: xdmp.parseDateTime("[Y0001]-[M01]-[D01]", xs.date("2013-04-21")) --

How to convert HTML to a Microsoft Word document ?

帅比萌擦擦* 提交于 2020-01-01 19:26:32
问题 How can I convert HTML from a CKEditor into a Microsoft Word document? 回答1: CKEditor is just HTML, so what you really should be asking yourself is: How do I save CKEditor contents as an HTML file and then convert that into a .doc file. The answer to the first part should be trivial. Protip: You send the contents as a string to your backend and your backend writes that string to an .html file. As for the conversion, you can try saving the content as a .html file, then opening that in Word and

How to Convert pythons Decimal() type into an INT and exponent

…衆ロ難τιáo~ 提交于 2020-01-01 08:38:09
问题 I would like to use the Decimal() data type in python and convert it to an integer and exponent so I can send that data to a microcontroller/plc with full precision and decimal control. https://docs.python.org/2/library/decimal.html I have got it to work, but it is hackish; does anyone know a better way? If not what path would I take to write a lower level "as_int()" function myself? Example code: from decimal import * d=Decimal('3.14159') t=d.as_tuple() if t[0] == 0: sign=1 else: sign=-1

RTF Format in Web Text Editor

可紊 提交于 2020-01-01 05:34:11
问题 Is there a text editor on the web that supports input from RTF-formatted documents? I know it is a bit of an odd request for webdev, but I need to read RTF documents from the database and edit them in a web-based text editor and store it back in RTF. Before I invest too heavily in a conversion tool, I thought I would ask if any of the many web text editors supported RTF. My research is showing that they don't. Additionally, since this is an MVC 4.6 application, would it be a huge effort to

Converting SVG file to Android Vector Drawable XML while keeping the group structure in place

南笙酒味 提交于 2020-01-01 04:16:26
问题 I want to convert SVG files to Android Vector Drawable XMLs. I need the structure of the SVG. To the extend that the SVG groups multiple elements together, I need that grouping to also be reflected in the Android Vector Drawable. Unfortunately, the tools I found to do SVG to Vector Drawable conversions try to minimize the file size in a way that gets rid of existing grouping in the structure of the file. Is there a smart way to do the conversion that leaves the grouping tree intact? 回答1: Have

How do I convert an array of arrays into a multi-dimensional array in Python?

大城市里の小女人 提交于 2019-12-30 23:30:33
问题 I have a NumPy array (of length X) of arrays, all of which are of the same length (Y), but which has type "object" and thus has dimension (X,). I would like to "convert" this into an array of dimension (X, Y) with the type of the elements of the member arrays ("float"). The only way I can see to do this is "manually" with something like [x for x in my_array] Is there a better idiom for accomplishing this "conversion"? For example I have something like: array([array([ 0., 0., 1., 0., 0., 0., 0

How do I convert an array of arrays into a multi-dimensional array in Python?

試著忘記壹切 提交于 2019-12-30 23:28:11
问题 I have a NumPy array (of length X) of arrays, all of which are of the same length (Y), but which has type "object" and thus has dimension (X,). I would like to "convert" this into an array of dimension (X, Y) with the type of the elements of the member arrays ("float"). The only way I can see to do this is "manually" with something like [x for x in my_array] Is there a better idiom for accomplishing this "conversion"? For example I have something like: array([array([ 0., 0., 1., 0., 0., 0., 0