简体   繁体   中英

How do you convert text to a number in Excel 2010

So I have this excel file that contains features from 211 cars and their values (eg fuel type, engine type, etc.). I have to do an analysis on that data using Orange, but I have one problem. A few of the features, for example fuel type, has values that are strings (diesel or gas). I want to convert that to a number, so that diesel becomes 0 and gas becomes 1 or whatever. Is there anyway to do this in excel 2010 without having to convert them manually? Thanks in advance.

Tim

You can use below formula (IF Function in excel)

=IF(A1="DIESEL",0,IF(A1="GAS",1,A1))

Syntax:

IF (CONDITION, VALUE_IF_TRUE, VALUE_IF_FALSE)

You will get output data as follows:

A           B
----------------------
DIESEL      0
GAS         1
OTHERS      OTHERS

Create a Table with two columns:

oil 0
gas 1 
...

then use

=vlookup(cell_w_string,Table_above,2,0)

where cell_w_string is a reference to you values that are strings and Table_above is Table created above. Should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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