Copying contents of columns with Field calculator in Qgis - qgis

I have to split the content of a column into 2 differents columns using the QGIS Field Calculator. Basically, my table is something like that:
Basically I have to work with descriptio column omitting characters from 1-12 and then copy next 8 characters (in this case "AgilisSi") into the PresLACAGI column.
The other element to copy is the final number in descriptio column, ranging from 1 to 3 characters. Possibly the best is thing would be a syntax that reproduces in CodiClapa column the number after ": ", including the space in the syntax.
Thanks a lot!

Use the field calculator, check Update existing field and select column from drop down and type in the Expression window for:
PresLACAGI: substr(descriptio,12,8)
CodiClapa: right(descriptio,3)

Related

PostgreSQL query to find a particular pattern in a text column

I have a text column in my database table which contains values like
A/B
A/B/C
A/B/C/D
A/B/C/D/E
Now, I want to select only those rows where this column value contains maximum three occurrences of '/'.
For clarity - expected output should be:
A/B
A/B/C
A/B/C/D
Can anyone help me with such a query?
I think it would be easier to simply remove everything else and count the number of remaining characters:
where length(regexp_replace(the_column, '[^/]', '', 'g')) <= 3
Online example

How can I rename several columns in dataprep?

I have more than 100 columns in dataprep whose names are like:
my column name 1
my column name 2
I would like to rename the name of the columns to be:
my_column_name_1
my_column_name_2
I have tried to do a rename, changing " " by "_". However, dataprep only changes the first whitespace! Is there any way to change all the whitespaces?
Another question, when I do a function like rename, it is done just for a column. I can add more columns writing the name of de column. Is there any way to select all columns without writing all the names?
thank you so much!
You can shift-select multiple columns to Transform when the data is in column view mode.
Select the columns to apply to and then choose the transformation.
JSDBroughton answer did the trick for me although it's not so clear how to do it. Change your view to Columns (second icon from the left on the toolbar). Select the first column, then hold Shift and select the last column. You should now have all columns selected. Then right clock and select Rename. A new Recipe step will be added with all your columns already added. Then set the Option to "Find and replace".
In terms removing all the spaces I couldn't find any Cloud Dataprep pattern or Regular Expression which let me replace all my spaces in my columns. Having said that my columns had a maximum of 4 spaces so I simply added the same step multiple times. I used the Regular Expression \s to match spaces and I replaced them underscores.

How to convert a fixed length string to multiple columns in Tableau

Using Tableau Desktop 10.x I have a column that contain a fixed length string starting with a letter and followed by 5 numbers.
For example: A12345. I would like to separate this column into two columns, where the first column would have the letter (A) and the second would have the 5 number string (12345). How can this be done in Tableau?
It can be achieved using this by creating Calculated fields .
click on analysis
1 write the name of the new column
2 in the box write RIGHT
3 choose the function RIGHT
4 add the original column name inside the square brackets, and follow with a comma followed by 1 (for the amount of elements)
More details

Breakout concatenated field into rows not columns within Tableau

I have two fields that contain concatenated strings. The first field contains medical codes and the second field contains the descriptions of those codes. I don't want to break these into multiple fields because some of them would contain hundreds of splits. Is there any way to break them into a row each like below? The code and description values are separated by a semicolon (;)
code description
----- ------------
80400 description1
80402 description2
A sample of the data:
One way is you can custom split two columns at ; which will create separate columns for every entry then you can pivot code columns and description columns separately.
One issue will be you can't guarantee if every code is mapped to correct description.
One more way is export data to excel sheet and then split and pivot the columns and then match the code and description, Then take the excel as datasource to the tableau.

Postgresql : How can I determine how many characters in a text

a column has type text and its data looks like "{U}{R}" or "{3}{U}{U}{U}".
How can I determine how many "U" contains this column?
I want to select those data who has at least one and at most three {U}.
You can remove the code U and compare the size before/after removing it. This difference is the number of occurrence.
select length('{3}{U}{U}{U}{R}{R}')-length(translate('{3}{U}{U}{U}{R}{R}','U','')) AS U_CNT;
--> 3
or more generaly
select length(colname)-length(translate(colname,'U','')) AS U_CNT;