I have a CSV file which contains numbers,date and text. I have to extract the column which contain the text.
For example, sample csv file look like
1-1-2000,1,2.3,TRUE
2-1-2000,1,2.3,FALSE
-
I want to extract the column containing the TRUE/FALSE values.
-
I want to convert the TRUE into 1 and FALSE into 0.
Please suggest some functions and sample code to do this
You can try this:
the line with
strtrimmight not be necessary if you know beforehand that there are never any trailing spaces. The line withstrcmpoutputs a logical array for all entries that string-compare to the literalTRUE, which implies that all other entries are false. Meaning:would produce the same logical vector. If you also want to explicitly compare to the string literal
FALSE, use something like this: