Find space in a list - string

I have a list (below) that is the output from an Excel table. The Excel table has 3 columns: Month, Col1, Col2 and the output format is CSV.
January,630648,97646 February,576204,87616 March,998287,142008 April,782340,118664 May,1678775,205862 June,1976671,295065 July,3349937,438844 August,0,0 September,0,0 October,0,0 November,0,0 December,0,0
I want to display this as an HTML table. I tried using List and Array functions, but could not achieve the desired result. How can I change the empty space to a delimiter, or is there a better way to do this?
Update from comments:
I am using cfspreadsheet to read an excel table with 3 columns
<cfspreadsheet src="../../../../file.xlsx"
action="read"
name="myquery"
sheetname="2014"
rows="6-17" columns="10,11,12"
format="csv"
columnnames="Month,Col1,Col2"
headerrow="4"
excludeheaderrow="false">
When I used the replace function; it did not do anything to the list. I then tried ListChangeDelims as suggested. However, that just changed the , to ; but the space remained as it is.

A list is just a string, so use one of the string functions.
replace(myString," ",";","all")
will replace all the spaces in the string with semi-colons.
You could also use ListChangeDelims() and convert the spaces to the delimiter that you want.
ListChangeDelims(list, new_delimiter [, delimiters, includeEmptyValues ])
So, this would change spaces and commas to semi-colons:
ListChangeDelims(myList,";",", ")
It's important to have both the space and the comma in the delimiters attribute.

Related

Formula to look for a word within a sentence

Here is the Sample Google sheet file
https://docs.google.com/spreadsheets/d/1B0CQyFeqxg2wgYHJpFxLIzw_8Pv067p0cwacWk0Nc4o/edit?usp=sharing
I have an Excel Sheet where I need to find Arabic Words and separate them.
For example, I have data like this:
//olyservice/GIS-TANSIQ01/Storage/46-أمانة منطقة عسير -بلدية بللحمر/حدود القري المطلوب اعتمادهاالمعتمد مسمايتها بالوزارة.rar
I'm looking for:
1st column: أمانة منطقة عسير
2nd column: بلدية بللحمر
3rd column: RAR
If there is no أمانة and بلدية words, the columns should be blank.
I tried these methods, without success:
=RIGHT(MID(A2,FIND("-",A2,20)+1,255),25)
and
=TRIM(MID(SUBSTITUTE(A2,"",REPT(" ",99)),MAX(1,FIND("-",SUBSTITUTE(A2,"",REPT(" ",99)))+21),99))
Since you specify certain key words to be found, we can look for those key words and then the relevant delimiter, based on your example.
In your example, أمانة is followed by the dash, and بلدية by the slash. (followed by is in terms of the right-to-left orientation of Arabic words).
Try this:
Col1: =MID(A1,FIND("أمانة",A1),FIND(CHAR(1),SUBSTITUTE(A1,"-",CHAR(1),LEN(A1) - LEN(SUBSTITUTE(A1,"-",""))))-FIND("أمانة",A1))
Col2: =MID(A1,FIND("بلدية",A1),FIND(CHAR(1),SUBSTITUTE(A1,"/",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))-FIND("بلدية",A1))
Col3: =TRIM(RIGHT(SUBSTITUTE(A1,".",REPT(" ",99)),99))
If the keywords are not found, the formula will return an Error. So you can just "wrap" the formula in IFERROR to have it return a blank if the key words are not present.
Edit:
The actual workbook does not have the same pattern as the sample you posted. In particular. Try this for column 2 data:
=MID(A2,FIND("بلدية",A2),99)
or with error suppression:
Col1: =IFERROR(MID(A2,FIND("أمانة",A2),FIND("-",A2,FIND("أمانة",A2))-FIND("أمانة",A2)),"")
Col2: =IFERROR(MID(A2,FIND("بلدية",A2),99),"")
And, the cells that are still returning the #VALUE! error do not have that keyword in the line.
For example:
A6: //olyservice/GIS-TANSIQ01/Storage/103-أمانة منطقة عسير -أحد رفيدة
does not contain بلدية
BTW, those formulas seem to both work on Sheets also.
Edit2:
Since you also posted an example in Sheets, if you can implement this in Sheets, you can use Regular Expressions to account for multiple terminations.
In that case, you would use:
=iferror(REGEXEXTRACT(A2,"(أمانة.*?)\s*(?:[-/\\.]|$)"),"")
or
iferror(REGEXEXTRACT(A2,"(بلدية.*?)\s*(?:[-/\\.\w]|$)"),"")
for the columns.
The regex extracts the pattern that begins with the key phrase, up to the terminator which can be any character in the set of -/\.A-Za-z0-9 or the end of the line. That seems to cover the examples in your sample worksheet, but if there are other terminators, you can add them to the sequence.
In Excel, this would require a VBA UDF to implement the Regex engine.

To extract a string based on some specific characters

I have values in rows like below:
Https://abc/uvw/xyz
Https://def/klm/qew/asdas
Https://ghi/sdk/asda/as/aa/
Https://jkl/asd/vcx/asdsss/ssss/
Now i want the result to be like below
Https://abc/uvw/xyz
Https://def/klm/qew
Https://ghi/sdk/asda
Https://jkl/asd/vcx
So how to take result by skipping / for up to some count or is there any other way to get this done in excel. Is there any way to skip result of the RIGHT when it Finds 4 '/' in string?
You could use SUBSTITUTE to replace the nth / (in this case 5th) to a unique character and perform a LEFT based on that unique character obtained from FIND. I'll take CHAR(1) as the unique character:
=LEFT(A1,IFERROR(FIND(CHAR(1),SUBSTITUTE(A1,"/",CHAR(1),5))-1,LEN(A1)))
Another option would be to split on / using Text to Columns under the Data tab and join back only the columns you need.

Excel - remove characters after a specific character

I have colum B with values:
0015-04D-SEAW
0015-ADLKM-SPOK
0015-D-CURR
0016-01N-BOIL
etc.
How can I remove all characters after second dash and the second dash itself as well, it should look like this:
0015-04D
0015-ADLKM
0015-D
0016-01N
Assuming B1 contains 0015-04D-SEAW
This would do : =IFERROR(MID(B1,1,FIND("-",B1,FIND("-",B1,1)+1)-1),B1)
Result : 0015-04D
One dirty solution would be to convert text to columns delimited by - and then to concatenate the first two columns separated by -

Import/convert list of space separated numbers to list of arrays in Matlab

I'm new to Matlab and I want to convert a column with space separated numbers (source is an Excel file) to a list of arrays.
In a first step I want to create a list of arrays like this:
Then I want to transpose the list like this:
Whats the correct command for this conversion?
I know it's a simple question, but I couldn't find a similar one.
First use xlsread to read in the raw text. The text will be read in as a cell array where each row of text is placed in a cell. Once you do this, it's a matter of splitting up the strings by spaces to create an additional cell array of cells per row, then inputting these cells into a function that creates an array of numbers. You can use cellfun combined with strsplit and str2double. Assuming your Excel file is called list.xls, do something like this:
[~,~,RAW] = xlsread('list.xls');
list = cellfun(#str2double, cellfun(#strsplit, RAW, 'uni', 0), 'uni', 0).';
list contains the desired output. I've also transposed the result as this is what you desire. I created an Excel file that's in the same fashion as how you've mentioned in your post. This is what I get when I run the code. First I'll show what list looks like, then we'll examine what the actual contents are:
>> list
list =
[1x4 double] [1x5 double] [1x6 double]
>> celldisp(list)
list{1} =
5405 5414 5420 9999
list{2} =
5405 5414 5430 5341 9999
list{3} =
5405 5419 5419 5419 5412 9999
Here's also what the MATLAB Variable Editor looks like:

remove only decimal place and not comma

Please i have 123,788.98, I want to remove the decimal place before storing in dbase so as to have just 123,789.
I tried round(123,789.98) but it gives me just 123.
Please how can remove the decimal place without removing the comma?
Divided with comma, these are two numbers. 123 and 788.98. So just round(788.98) and insert them both in one row.
INSERT INTO table(row) VALUES ('123,'.round(788.98).'')
If you have a comma, you can create two variables from the form input:
list($one, $two) = explode(",", "S_POST['amount']", 2);

Resources