Libreoffice calc concatenate cell contents and parenthesis - concatenation

Using Libreoffice Calc, here's what I'd like to do...
Where
A1=XYZ
A2=123
A3=ABC
I'd like to output into a single cell, this:
123_ABC (XYZ)
So here's what I did...
=CONCATENATE(A2,"_",A3," (",A1,")")
But calc doesn't like it at all. I assume it has to do with the combination of " and ) characters.
Is it possible?

My problem was the use of commas rather than semicolons.
Solution:
=CONCATENATE(A2;"_";A3;" (";A1;")")

Related

Remove spaces after commas in Google Sheets

I would like to ask if there is some shortcut/function how to remove all spaces after commas in Google Sheets?
Here is link to a template https://docs.google.com/spreadsheets/d/1jweedL8iURMfi-CNYDiRQRb0GZO2ji9cyTTTMf6pFk4/edit?usp=sharing.
I have a sheet which contains many data looking like this (more words in one section, separated by commas and there is space after each comma). However, I need the sections without the spaces after commas (e.g. "dog,cat"). I would like to apply it on the whole sheet.
Any suggestions, please?
Thank you very much.
If you're looking for a formula to do this, try this in cell C1:
=arrayformula(regexreplace(A:B;",\ ";","))
So if you wanted a new Sheet Hárok2 to copy Hárok1, you'd add this to cell A1 on Hárok2:
=arrayformula(regexreplace('Hárok1'!A:Z;",\ ";","))
Just go to Edit then Find and replace. Enter , in Find and enter , in Replace then go and Replace either one by one or everything in one go.

SQL Pattern matching not giving the correct output

I am trying to find a certain set of characters in a column from a datatable. I have tried the pattern that seems more logical to me (right below) but it doesn't seem to be doing the job. What I wish to achieve is a pattern where I have something like '["5"]', basically with: square brackets, quotation marks, any integer number, quotation marks, square brackets. The output I am getting is just empty, and I can't seem to undersand why. Besides this, I would like to update the records that do not follow this pattern to follow it. Does anyone have a solution for this?
To give you some context, here is the test table:
I want to achive only the last three records.
Here is what I have tried:
SELECT ToJsonTestValue
FROM Test
WHERE ToJsonTestValue LIKE '["%"]'
and
UPDATE dbo.Test
SET ToJsonTestValue = '["'+ToJsonTestValue+'"]'
WHERE ToJsonTestValue LIKE '#';
You have a couple of problem here. Firstly you have the square brackets, which needs escaping. Then you also use % which is a multi character wildcard, however, it appears that you want a single character. It also appears that that character can only be an integer, so you might want to be more specific. Either of these should give you the result you want:
--Using single character wildcard:
SELECT *
FROM (VALUES('["1"]'),('["["1"]"]'))V(S)
WHERE V.S LIKE '[[]"_"[\]]' ESCAPE '\';
--Specifically requiring int:
SELECT *
FROM (VALUES('["1"]'),('["["1"]"]'))V(S)
WHERE V.S LIKE '[[]"[0-9]"[\]]' ESCAPE '\';

Modify and Concatenate in the same formula possible?

I have a Google spreadsheet with more than 1000 rows of data. Column A has unique ID numbers. Column B has video file names. If possible, I'd like to do the following in a single formula:
Enclose the base filename in square brackets (file extension should not be enclosed).
Concatenate columns A and B.
Output the result to Column C.
See screenshot below.
Is this possible without scripts and in a single formula? I tried the formula below but I get a parse error.
=ARRAYFORMULA(A:A&" ["&(SUBSTITUTE(B:B,.mp4,"]"&".mp4")))
*SUBSTITUTE above means I'm trying to substitute ".mp4" with the closing square bracket.
try:
=ARRAYFORMULA(IFNA(A2:A&" ["&
REGEXEXTRACT(B2:B, "(.+)\.")&"]"&
REGEXEXTRACT(B2:B, "(\..+)")))
or:
=ARRAYFORMULA(A2:A&REGEXREPLACE(B2:B, "(.+)\.", " [$1]."))

Using dlmwrite to write cell objects MATLAB

I have a cell array with 7 columns. All these columns contain strings. I want to write this cell array into a text file. To start, I was doing this on only 1 element of the cell and this is my code:
dlmwrite('735.txt',cell{1},'delimiter','%s\t');
cell{1} looks like this:
Columns 1 through 2
[1x30 char] [1x20 char]
Column 3
'Acaryochloris'
Column 4
'Cyanobacteria001'
Columns 5 through 6
'Cyanobacteria00' 'Cyanobacteria'
Column 7
'Bacteria'
It gives me the output without separating the columns. Sample output is:
Acaryochloris_marina_MBIC11017AcaryochlorismarinaAcaryochlorisCyanobacteria001Cyanobacteria00CyanobacteriaBacteria
The correct output should have spaces between all the columns :
Acaryochloris_marina_MBIC11017 Acaryochloris_marina Acaryochloris Cyanobacteria001 Cyanobacteria00 Cyanobacteria Bacteria
Note that for the second column, we need to add the underscore between Acaryochloris and marina. There is originally a space between those two words.
I hope I explained the problem correctly, Would appreciate the help. Thanks!
DLMWRITE is for numerical data. In your case it process the char data as numbers, each character as a time. You probably view the resulted file in such a way that you don't see tab delimiters.
You can use XLSWRITE to write cell string array to a file. If you don't want the output to be in Excel format, run DLMWRITE before it to write some number to a file.
dlmwrite(filename,1)
xlswrite(filename, Acell{1})
Don't call you variable cell, which a keyword in MATLAB.
As an alternative you can write to a file with lower level function, like FPRINTF.
UPDATE:
If you want to use XLSWRITE in a for-loop and not to overwrite the data you can specify the row to start from:
dlmwrite(filename,1)
for k = 1:10
xlswrite( filename, Acell{k}, 1, sprintf('A%d',k) )
end
UPDATE 2:
Unfortunately it does not work anymore in the latest MATLAB releases (I believe starting from R2012b). XLSWRITE gives error about wrong file type.
Something along the lines of the following should do what you want:
fid = fopen('735.txt', 'w');
fprintf(fid, '%s\t', cell{1}{:});
fclose(fid);

SQL Server Escape an Underscore

How do I escape the underscore character?
I am writing something like the following where clause and want to be able to find actual entries with _d at the end.
Where Username Like '%_d'
T-SQL Reference for LIKE:
You can use the wildcard pattern matching characters as literal characters. To use a wildcard character as a literal character, enclose the wildcard character in brackets. The following table shows several examples of using the LIKE keyword and the [ ] wildcard characters.
For your case:
... LIKE '%[_]d'
Obviously #Lasse solution is right, but there's another way to solve your problem: T-SQL operator LIKE defines the optional ESCAPE clause, that lets you declare a character which will escape the next character into the pattern.
For your case, the following WHERE clauses are equivalent:
WHERE username LIKE '%[_]d'; -- #Lasse solution
WHERE username LIKE '%$_d' ESCAPE '$';
WHERE username LIKE '%^_d' ESCAPE '^';
These solutions totally make sense. Unfortunately, neither worked for me as expected. Instead of trying to hassle with it, I went with a work around:
select *
from information_schema.columns
where replace(table_name,'_','!') not like '%!%'
order by table_name
I had a similar issue using like pattern '%_%' did not work - as the question indicates :-)
Using '%\_%' did not work either as this first \ is interpreted "before the like".
Using '%\\_%' works. The \\ (double backslash) is first converted to single \ (backslash) and then used in the like pattern.
Adding [ ] did the job for me
like '%[\\_]%'
This worked for me, just use the escape
'%\_%'
None of these worked for me in SSIS v18.0, so I would up doing something like this:
WHERE CHARINDEX('_', thingyoursearching) < 1..where I am trying to ignore strings with an underscore in them. If you want to find things that have an underscore, just flip it around:
WHERE CHARINDEX('_', thingyoursearching) > 0
Adding to Gerardo Lima's answer, I was having problems when trying to use backslash as my escape character for the ESCAPE clause. This caused issues:
SELECT * FROM table WHERE email LIKE '%#%\_%' ESCAPE '\'
It was resolved by switching to an exclamation point. This worked:
SELECT * FROM table WHERE email LIKE '%#%!_%' ESCAPE '!'

Resources